How to Translate WordPress Plugins or Themes using Poedit Software

enquerer > Blog > Developers > How to Translate WordPress Plugins or Themes using Poedit Software

If you are trying to translate your favorite plugin or theme into other languages, we have multiple choices.

  1. Using translation plugins
  2. Using gettext translation method

In this article, we are going to briefly explain how we can translate our WordPress plugins or theme into other language using one popular gettext translation tool called Poedit.

Before beginning translation, we need the following:

  1. We have to install Poedit software on our computer. The software is available on the software website (http://poedit.net/) for all operating systems. The free version is enough for our translation purpose.
  2. The POT file of our favorite plugin. The POT file will be available in the `language` directory of your plugin or theme.

Before beginning, it is better to know about some terms used in this step.

POT file: POT files are the template files for PO files. They will have all the translation strings left empty. A POT file is essentially an empty PO file without the translations, with just the original strings. The plugin or theme developer has to provide this file to us.

PO files: PO files are the files which contain the actual translations. Each language will have its own PO file. For example, for French, there would be a fr.po file, for German, there would be a de.po, and for American English, there might be en-US.po.

MO files: MO or Machine Object is a binary data file that contains object data referenced by a program. It is typically used to translate program code and may be loaded or imported into the GNU gettext program.

POT file is used whenever someone starts a new PO file for translation to a new language. So the workflow is POT (original strings) to PO (original strings and their translations to a specific language) to MO (compiled binary results).

So our process aim is to create MO files & PO files from plugin POT files using Poedit software.

If both prerequisites are ready & you got a basic idea about the terms used in the translation steps, we can start the translation. 

1. Open the Poedit Software & Create New Translation

2. Locate the POT file of the Plugin you wish to translate.

3. Choose the language the plugin to be translated into.

Note: WordPress uses a language code for each & every language. We have to follow the same practices & otherwise the translation won’t work. For the list of language codes WordPress uses, please click this LINK: (http://www.aurodigo.com/2015/02/wordpress-locale-codes-complete-list.html).

4. Once we selected our language, we can now begin the translation.

Once done, click File > Save As menu in the software.

5. Confirm that we saved the file in the correct format.

The format should be plugin-text-domain-language_code. If your plugin text-domain is my-plugin, the translated file is to be saved as my-plugin-{locale}.mo. For example, the locale for German is de_DE. If the text domain is ‘my-plugin’, the German MO and PO files should be named my-plugin-de_DE.mo and my-plugin-de_DE.po.

The text domain of any plugin(if it’s translatable) can be found in the main plugin file. Same way, the text domain for the theme can be found in the theme’s style.css file.

Once we click save, PoEdit software will automatically generate .po and .mo for you.

6. Upload these two files in wp-content/languages/plugins directory for plugins & wp-content/languages/themes directory for themes.

If you do not have this languages directory in your wp-content directory then simply create it & upload files.

7. Change the local language in WordPress. 

Once you have added the .po and .mo to the proper location, go to your WordPress Dashboard > Settings > General  & change your Site language to the same language as your Poedit translation.

8. Check your site & confirm that it is working.

Leave a Comment