How to Translate a WordPress Plugin

How to translate a WordPress Plugin

You have just downloaded that Plugin that you were eager to install and run on your site.

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 __e() or __()). 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:

  1. Download the POT file that the plugin developer supplied
  2. Open Poedit, and select to create a new translation (see below)
Select Language
  1. 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.
  2. 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
Languages Folder
  1. 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
Select Language
  1. 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:

define('WPLANG','nl_NL')

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.

Conclusion

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.

Other posts you might like

WordPress Translation You have just decided that you wanted to present your blog or website in another language, great! WordPress translation at first seems daunting.
Adapting a Marketing Strategy for Multilingual Content Given the worldwide reach of the internet, digital marketing will have to inevitably be adapted for multilingual content. In fact, according to current
WooCommerce Localization Woocommerce localization (translation) is not a complicated affair. Given the great popularity behind Woocommerce, there has been a lot of investment in translating the plugin.
Language Switcher Best Practices If you have a site with multilingual content, you would possibly consider using redirects based on the language chosen on a user's browser.
Other posts you might enjoy:
Pascal Evertz
p.evertz@buyersunited.nl