WordPress : Translate a Plugin

First off, you have to know that not all WordPress plugins can be translated. The plugin developer(s) had to take the necessary steps such as using the WordPress __() and _e() functions and load_plugin_textdomain() in order to parse the strings/text of the plugin through the localization system.

If you have a plugin with the ability of being translated, this tutorial will guide you through the steps of translating the plugin using an application called poEdit with screenshots taken on the Macintosh operating system. poEdit is available for Windows and Linux users as well though.

Before we get started, you’ll need to obtain poEdit from the poEdit website. It is a free and has been released under an MIT license, which allows you to download, edit and redistribute the source code as long as the original license information is kept intact.

I am going to translate the WordPress Mailing List plugin. I have my plugin folder ready for use, placed on my desktop where it is easily accessible. I will now open poEdit and go to “File” > “New Catalog…” to create a new catalog file for this plugin.

The moment I click “New Catalog…”, the application displays a dialog window with three (3) tabs at the top. The first tab is called “Project Info”. The only mandatory field is the “Project Name”, though you can fill all of them in if you want to.

The second tab is called “Paths” and gives you the ability to specify the base path and other paths to the PHP files which need to be translated. In this tutorial, I’m going to place the catalog file directly into the plugin folder, so I’m using a dot “.” for the “Base Path” field and I create a new path item and fill in a dot “.” as well. See the screenshot below.

The third and last tab is called “Keywords”. It has a blank, white area and some buttons to the top-right. The second button from the left allows you to create new keyword items. Create two keyword items. The first one is a double underscore “__” and the second item is underscore and the letter E (in lowercase) “_e”.

When you are done with this, simply click “Ok”. The poEdit application will now open a new dialog prompting where you would like to save the .PO file. Navigate to the plugin folder, type in the desired name for the catalog file and save it inside of the plugin folder.

Save the catalog file by hitting the “Save” button. Next up, the poEdit application will immediately start a scan which will scan through each and every one of the PHP files inside the directory based on the details you filled in the “Paths” section in the “Project Info” dialog before. When it is done scanning, it will display all the translatable strings/text and show you how many there are as well.

Now click “Ok” and you can start translating the available strings. For each string you click on, the application will display the original text in a box and provide you with another text area where you can type the translation.

With all the strings translated according to your preference, save the catalog file inside of the plugin folder and upload it together with the rest of the plugin files to your WordPress installation. WordPress should automatically load the language file when the plugin is loaded and in case it does not do that, you might need to open up your “wp-config.php” file and set the WPLANG constant to the appropriate language.

All the best of luck!

%d bloggers like this: