How to edit .po language files in WordPress themes

If you have just bought some fancy theme and while trying to to localise run into .po, .mo, and .pot files – you will need special tool to make changes to them. This article explains how to take a .po file that is included with your WordPress theme and/or plugin download and translate it into your native language.

So what the heck are those .mo, .po, and .pot files anyhow and why are they included in my download?

Well, the files aren’t really important if English is your primary language but if you want to have WordPress, a WordPress theme, or even a plugin localized in your native language then those files are golden.

  • .mo stands for Machine Object
  • .po stands for Portable Object
  • .pot stands for Portable Object Template

The file that you want is ideally a .po file since it’s the raw editable text scraped from the entire WordPress theme/plugin. The .mo file is the compiled export of the .po file which is used by WordPress.

Here are the steps to translate/localize a .po or .pot file into another language

  • Download a gettext file editor like Poedit and install it.
  • Open the English .po file that came with your WordPress theme or plugin with poedit. If you only got a .pot, just rename it to .po and open it in poedit.
  • Now go through and translate all the text one line at a time in the bottom box.
  • Then “File” > “Save as” to your desktop or a folder on your computer. This will output both .po and .mo file.

Some text characters need to be converted into html entities otherwise they will not display correctly. A very common example is a word containing an apostrophe or single quote (‘) which needs to be replaced with ' — for example, Chloe O’Brian should be written as Chloe O'Brian. For a complete list of html entities, visit W3Schools.

You will also need to make a change to your WordPress wp-config.php file (located in your WP root directory) with the correct language codes like the example below. If you don’t have a WPLANG entry then you can create one by adding line below int your wp-config.php file. The sample below is for Brazilian language and you can find all language codes in here.

define ('WPLANG', 'pt_BR');

For more resources about how to translate WordPress into your language click here.