Creating .pot file for your theme or plugin

I’ve been re-thinking my thoughts about internationalizing WordPress themes or plugins. For now I have always used Poedit for generating my .po/.mo file and not even included .pot file in a theme or plugin. It has worked pretty well and I know that my finnish translations are working just fine.

But with latest theme project I started to think that how do I translate custom page template names? After that I wondered how can I translate theme description from `style.css` and other header info?

David Decker had thought about it and said that he uses Codestyling Localization plugin for this and manually adds proper header info. For user translations he uses GlotPress. That seems a great work flow for generating .pot file for your themes and plugins.

Then I remembered that Tom McFarlin had a blog post about How To Internationalize WordPress Plugins. I read it again and understood it a lot better. Then I checked Twenty Twelwe theme and realized that it has twentytwelve.pot file and it contains strings for custom page template names and for theme description and all!! I want to do the same, right now and right here!

Generate .pot file in Windows

Most of this is from Tom’s article but I have W7 and XAMPP so the process is a little bit different but not hard. But first, why we should even gererate .pot file for our theme or plugin users? Why Poedit might not be the best choice for this.

  • .pot file is the first template to use and .po/.mo files are generated from it. We don’t know which software translators are gonna use and .pot extension is the most generic one.
  • Poedit doesn’t pick up custom page template names automatically, even if I found a way to do it.
  • Poedit doesn’t include theme description and other header info from `style.css`.
  • Poedit doesn’t pick up translators notes like this `/* translators: */`.

Use i18n tools from repo

In WordPress repo there is tools for generating correct .pot file. They can be found here.

Now we want to checkout those files from trunk. I created folder `tools` in `wp-content/themes` and checkout trunk using TortoiseSVN. Just right click your mouse and choose SVN Checkout and you can checkout all the files in the folder `wp-content/themes/tools`. Note that I’m using XAMPP and localhost for this.


Then open your XAMPP control panel and open your shell terminal from the right.


After that navigate the the right folder, I used `cd htdocs/foxnet-themes/wp-content/themes`. To generate .pot file we need to use command like this.

php tools/makepot.php wp-theme theme-folder-name

This scans your folder (theme) `theme-folder-name` and generates file `theme-folder-name.pot` in `wp-content/themes`. Naturally you’ll want to move this file to correct folder in your theme, perhaps in `languages` folder.

For plugins you can use command like this.

php tools/makepot.php wp-plugin plugin-directory

For example I used command

php tools/makepot.php wp-theme kalervo

for my theme and moved `kalervo.pot` file to folder `wp-content/themes/kalervo/languages`. I got some notices but this really works great and now there is no need to manually add theme description, page template names and all the other header info.

Note! You still need to use your text domain in your plugin header or theme header in `style.css` so that custom page template names and theme description translations actually gonna work. So add this in header.

Text Domain: my-text-domain

And replace `my-text-domain` with your actual theme or plugin text domain.

What about Poedit?

I still use Poedit for my translation work. As a matter a fact I have already translated most of the strings in my theme using Poedit before I created correct .pot file. Do I have to do everything again now? I could have manually copy and paste translations from old file to new file but luckily there is a Update from POT file function in Poedit. It’s under Catalogue.


With this command users or I can update their existing .po files using Poedit. Naturally other tools like GlotPress are better for community translations. But that’s another topic. I hope you liked this one.

Edit: When using Update from POT file in Poedit, it doesn’t clean up the obsolete text strings. You’ll have to do it manually opening up .po file and look for the end of the file. Just delete all the strings that starts with `#~`. Notice the `~` sign.