11 May How to translate a WordPress Plugin
If you are reading this article in another language than English, it has been automatically translated by our WordPress Multilingual Plugin.
However, given that your website is multilingual, you have to translate the plugin so that it’s functionality extends to the other language versions of your site. Fortunately, it does not have to be a complicated procedure to Translate a WordPress plugin.
Translation ready Plugins
Before you can embark on translating a WordPress plugin, you have to make certain that the plugin is ready to translate. This means that the developers of the plugin have coded the plugin according to the GNU gettext localization framework.
Unlike theme searches, you are not able to filter your plugin search and restrict it to those that are translation ready. Hence, it makes sense to read the plugin description beforehand to make certain that it is ready. Similarly, before you purchase any premium plugin, make certain that the developers have made it translation ready.
Plugin translation with Poedit
When it comes to methods to translate a WordPress plugin, there are three files types that are used the localization framework. These are POT (Portable Object Template), PO (Portable Object) and MO (Machine Object) files. POT files contain all of the source text that has been extracted from the WordPress source code (text wrapped in
__()). PO files are used for completing the translations in your target language. You will have the English text and completed translation as well. Lastly, MO files are binary versions of your PO files. These will be used by the server to show the translations.
In order to translate a WordPress plugin, you will need a program called Poedit. This is an open source piece of software that will work on both Mac and Windows. The below example assumes that the plugin developer has provided a POT file. In the unlikely event that the developer has not included one, but has used the GNU gettext framework, then you can generate your own POT file using Poedit. This was covered in a previous blog on how to translate a WordPress theme. The procedure is identical for plugin translation.
For the purposes of illustration, we will be translating an “example” plugin into Dutch. Once you have installed Poedit, follow these steps to complete the translation:
- Download the POT file that the plugin developer supplied
- Open Poedit, and select to create a new translation (see below)
- Select the POT file that you have downloaded. You will be asked which language you would like to translate into. In this case we are translating into Dutch (Netherlands). Poedit will automatically save a version of this .po file as well as a .mo file in your directory.
- You can begin translating into Dutch. As you can see, the source English text is at the top and the translations must be completed below in the destination boxes
- Once, completed, save the file in your languages folder for your plugin. Poedit will automatically save the file in the correct format required. In this case it will be nl_NL.po
- After translating the plugin, you will need to upload it back onto your WordPress. You can either upload it via FTP or by adding a plugin in the WordPress Admin.
Configuring WordPress for the translated Plugin
Now that you have translated your Plugin, you will need to configure your WordPress to read the translated files. In your WordPress install file, open up the wp_config.php file. Insert this little snippet of code:
What this does is it tells WordPress to use Dutch (Netherlands). You will need to adapt this code for the language code that you will be translating for. It is important to note that this will only translate the plugin. The WordPress admin area will still be in English.
Fortunately, for many of the most popular plugins, completed translations already exist. This is thanks to all of the contributors to the WordPress initiative. If, however, the translation does not exist for the language that you are attempting to localize for, a professional translation service would be able to assist. If you have completed the translation and would like to give back to the WordPress community, you can upload it to the repository.