Posted on

Translating Plugins To Your Language

Some of my plugins use settings in the main application settings page to set labels on the user interface.    However, MOST of the admin interface instructions and labels and some of the labels on the user interface can only be changed by using the WordPress language translation system.

To create a translation file you will need to download the latest .pot file for the plugin that you wish to translate, then create a .po file from it.    The easiest way to start is simply copy the .pot file to a new <locale>.po file, such as da_DK.po.

All of my plugins have a languages subdirectory that contains the .POT and some .PO files that have already been translated.

POT files

After the strings are marked in the source files, a gettext utility called xgettext is used to extract the original strings and to build a template translation POT file. Here is an example POT file entry:

#: wp-admin/admin-header.php:49
msgid "Sign Out"
msgstr ""

PO files

Every translator takes the WordPress POT file and translates the msgstr sections in their own language. The result is a PO file with in the same format as a POT, but with translations and some specific headers.

Naming The PO and MO Files

The .po and .mo files should follow the standard naming convention which is:

<text_domain>-<language code>_<country code>.<po|mo>

For Store Locator Plus, the text domain is csa-slplus.   You can see this in the top of the store-locator-le.php file as part of the comment, however not all plugins will have that helpful hint.    You should look for the load_plugin_textdomain function call within the plugin to find the true identity of text_domain.     This is on line 241 in the storelocatorplus-actions_class.php file (for Store Locator Plus version 3.11) which reads load_plugin_textdomain(‘csa-slplus’,false, SLPLUS_PLUGINDIR.’languages/’);

The language code is one of the pre-defined language codes as defined by PHP.   This is typically a lowercase pair of letters such as “en” for English or “es” for Spanish.

The country code is one of the pre-defined 2-letter country codes.  For example, US for USA, GB for United Kingdom, for Canada.

The combination of language plus country code allows for nuances in the language that my vary by specific location.

Thus, for an American translation the file name for Store Locator Plus would be csa-slplus-en_US.po and   For The United Kingdom it would be csa-slplus-en_GB.po and

Using Codestyling Localization Plugin

I recommend using the Codestyling Localization plugin to make it far easier to create the related PO files.   This plugin reads the plugin directory and provides a web based interface for creating translations.

Send Your Translation

If you create a .po translation file, please send it to us at info_at_charlestonsw_dot_com or post it in the forums.  Tell me which plugin or add-on pack and which version of the plugin you created it for, and I will include it in the next public release.

Also, if you send a complete translation file,  I’ll grant access to the premium add-on packs for your account!

Related Resources