WordPress L10n: How to Translate Your Plugin

Share this article

In the first part of this series on WordPress plugin i18n and l10n, we learned how to internationalize a WordPress plugin. This second (and concluding) part will be a walk-through on making a plugin ready for translation, as well as learning how to localize or translate a plugin into a new language. The process of making a plugin ready for translation is fairly straight-forward. First of all, you’ll need to generate a .pot file. This file is used by translators to translate your plugin into a new language. This .pot file contains the original strings (in English) of your plugin. Here is an example POT file entry:

#: plugin-name.php:123
msgid "Welcome to SitePoint"
msgstr ""
A translator looking to translate the text Welcome to SitePoint (at line 123 in your plugin file) into German will add the translation between the quotation marks.
#: plugin-name.php:123
msgid "Welcome to SitePoint"
msgstr "Willkommen auf SitePoint"

Generating POT file

As previously mentioned, the POT file is the one that is handed to translators, so that they can do their work. Take note: before generating your plugin POT file, ensure you’ve internationalized your plugin. There are a couple of ways to generate a POT file for your plugin.

Plugin Repository Admin Tools

The official WordPress plugin repository has a tool for generating the POT file of a plugin which is located at the Admin page of every plugin listing. To access the Admin page of your plugin, login to the plugin repository and click the green Admin button on the sidebar. Admin Tools Follow the short guide below to see how easy it is to generate POT files using the admin tool.
  • Click on Continue in the Generate POT file section. POT File
  • Then click on Get POT to download the POT file.
POT File


There are a number of Gettext translation editors but Poedit is popular among the WordPress faithful. The pro version allows you to create the PO/POT file with one click. If you don’t have the pro version you can easily get this Blank POT and use it as the base of your POT file. Once you have placed the blank POT in the languages folder of your plugin, double-click on it and open it with Poedit. Click Update
in Poedit to update the POT file with your plugin strings. Poedit Finally, click File > Save or Ctrl + S to save the changes. If you own a Pro version of this tool, generating the POT file is as easy as following the steps below.
  • Click File > New WordPress translation and select your plugin folder.
  • Poedit will skim over your plugin files and extract the translatable string.
  • Select the language of the translation from the pop-up dialog box.
  • Ctrl + S and explicitly save the file as .pot.
  • You can save the file as .po and afterwards rename it to .POT.
Language Selection A PO and a POT file are similar in that they have the same content format. The subtle differences between them are:
  • It is the .pot file that is used by a translator and not the PO file.
  • It is from the resulting .po translation file a .mo file is compiled.
It is a good idea to offer the POT file along with your plugin, so that translators won’t have to ask you specifically about it.

Plugin L10n

Localization describes the subsequent process of translating an internationalized plugin into a new language.

How to Localize a Plugin

To localize a plugin, grab the plugin POT file, open it in a text editor, and enter the translation of every string at their respective msgstr sections, in between the quotation marks. Save the file in this format my-plugin-{locale}.po where the {locale} is the language code and/or country code that you defined in the constant WPLANG in the file wp-config.php. For example, the locale for German is de_DE. The my-plugin is the text domain of the plugin. Remember, it is from the .po
file that the resultant .mo file (used by WordPress in translating a plugin) is generated. Let’s see how to generate the MO file from the PO file.

Online PO to MO converter tool

There are a couple of online tools that convert a .po file to a .mo file. Personally, I use the tool at tools.konstruktors.com. PO to MO Converter To generate a MO from a PO file, upload the .pot file. The tool will automatically convert the file, and provide you an .mo file for download.

Using Poedit for L10n

Poedit provides a simple interface for translating plugin strings or texts and can also generate the required MO file from a PO file. To localize or translate a plugin into a new language using Poedit, follow the guide below.
  1. Open the plugin .pot file with Poedit.
  2. Click on the translatable strings and enter their respective translation in the text area labeled Translation. Poedit
  3. When you are done with the translation, save the file in this format my-plugin-{locale}.po. E.g. espw-plugin-de_DE.po where espw-plugin is the text domain and de_DE as the locale.
On saving the PO file, the MO file is automatically generated. If a translator sends your plugin translation file (the MO and PO files) to you, copy the MO (.mo) file to your plugin language folder for use by WordPress. When a user operating a Localized version of WordPress uses your plugin, the plugin will then be in their language.

Wrap Up

If you want your plugin to reach the widest possible audience, internationalize it and make it translation ready. Although you might only be proficient in one language, if you make your plugin ready for translation, it opens up the possibility for people to voluntarily translate your plugin. If you have any questions, suggestions or contributions, I would be happy to hear them in the comments.

Frequently Asked Questions (FAQs) about WordPress L10N and Plugin Translation

What is the significance of WordPress L10N in plugin translation?

WordPress L10N, also known as localization, is a crucial aspect of plugin translation. It allows developers to create plugins that can be easily translated into different languages. This is particularly important for plugins that are used globally, as it ensures that users can interact with the plugin in their native language, enhancing user experience and accessibility.

How does WordPress L10N work?

WordPress L10N works by using gettext functions, which are built into PHP. These functions allow developers to mark certain strings of text within their code that can be translated. These strings are then extracted into a POT (Portable Object Template) file, which can be used as a template for creating PO (Portable Object) files in different languages.

What are the key components of WordPress L10N?

The key components of WordPress L10N are the gettext functions, POT files, PO files, and MO (Machine Object) files. Gettext functions are used to mark translatable strings, POT files serve as templates for translations, PO files contain the actual translations, and MO files are binary files that are used by WordPress to quickly load the translations.

How can I create a POT file for my WordPress plugin?

To create a POT file for your WordPress plugin, you can use a tool like Poedit or the command-line tool xgettext. These tools scan your plugin’s PHP files for gettext functions and extract the translatable strings into a POT file.

How can I translate my WordPress plugin into a specific language?

To translate your WordPress plugin into a specific language, you first need to create a PO file for that language using your POT file as a template. You can then use a tool like Poedit to translate the strings in the PO file. Once you’ve translated all the strings, you can save the PO file and compile it into an MO file, which can be used by WordPress to display the translations.

What is the role of gettext functions in WordPress L10N?

Gettext functions play a crucial role in WordPress L10N. They are used to mark strings of text within your plugin’s code that can be translated. This allows these strings to be extracted into a POT file, which serves as a template for creating PO files in different languages.

How can I ensure that my WordPress plugin is fully localized?

To ensure that your WordPress plugin is fully localized, you need to make sure that all translatable strings in your code are marked with gettext functions. You also need to create a POT file, translate it into the necessary languages, and compile the translations into MO files.

Can I use WordPress L10N to translate my plugin’s admin interface?

Yes, you can use WordPress L10N to translate your plugin’s admin interface. Just like with the front-end of your plugin, you need to mark all translatable strings in the admin interface with gettext functions, create a POT file, and translate it into the necessary languages.

What tools can I use to assist with WordPress L10N?

There are several tools that can assist with WordPress L10N. Poedit and xgettext are popular for creating POT files and translating PO files. There are also several WordPress plugins, such as Loco Translate, that provide a user-friendly interface for translating plugins directly within WordPress.

How can I test my WordPress plugin’s translations?

To test your WordPress plugin’s translations, you can change the language of your WordPress installation to the language you’ve translated your plugin into. You should then be able to see your plugin in that language. If you notice any untranslated strings or errors, you can go back to your PO file and make the necessary corrections.

Collins AgbonghamaCollins Agbonghama
View Author

Collins is a web developer and freelance writer. Creator of the popular ProfilePress and MailOptin WordPress plugins. When not wrangling with code, you can find him writing at his personal blog or on Twitter.

Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week