Wordpress - How to create .pot files with POedit?

Here is how you can create a .pot file for your theme with Poedit (free edition, version 1.6.10) on OS X.

Best practise is to save language files in a folder named "languages" in your theme directory. If you haven't already, create it before you start.

In Poedit:

  1. In the "File" menu select "New"
  2. Select the language that you used in your theme (probably English)
  3. In the "Catalog" menu select "Properties"
  4. Enter the project information in the "Translation properties" tab
  5. Go to the 3rd tab "Sources keywords"
  6. Click on the "New item" button (2nd button) and enter a keyword and repeat this for each of your keywords (__, _e, esc_attr_e, etc.)
  7. Click on the "OK" button at the bottom
  8. In the "File" menu select "Save As.."
  9. Save the file as "yourthemename.pot" in the "languages" folder in your theme directory (make sure you add the .pot extension to the filename because by default it will save as .po)
  10. In the "Catalog" menu select "Properties" again
  11. Go to the 2nd tab "Sources paths"
  12. Set the value for "Base path" to ../ (the .pot file is saved in a subdirectory so this way you set the base to the parent directory, ie. your theme directory)
  13. Next to "Path" click on the "New item" button and enter . (this will make it scan your theme directory and its subdirectories)
  14. Click on the "OK" button at the bottom
  15. In the project window click on "Update" (2nd icon at the top)
  16. In the "File" menu click "Save"

And you're done :)


You can do this with the WordPress tools, without POEdit.

First, do an svn checkout of http://develop.svn.wordpress.org/trunk/:

svn co http://develop.svn.wordpress.org/trunk/ wpdev

Then, switch to the i18n tools directory in it:

cd wpdev/tools/i18n/

Then just run the makepot.php over your theme's directory:

php makepot.php wp-theme /path/to/your/theme themename.pot

This will create a themename.pot file for you. Use it in any standard translating tool you like.

This is better because it uses the WordPress code to find the i18n functions, so you won't miss any of them. Additionally, it will find and add things like the theme header information, such as the name, description, etc. This allows for those to be translated too. Make sure you include the "Text Domain:" header in your style.css for those to work.


I found the easiest way now is to use the WP-CLI. Navigate to your theme or plugin and execute the following command (after WP-CLI is installed):

wp i18n make-pot . languages/my.pot

(See documentation of the command)

You can then edit this file with Poedit or any other handy translation tool.