How to Translate My Plugins

I’ve been asked many times to provide information on how to translate my plugins into another language. In an effort to help make my plugins multi-lingual, I have supplied this information below. Please don’t be overwhelmed by the amount of detail as the translation process is actually quite easy. The feedback I have so far is that is an interesting exercise and takes around 2-4 hours to complete.

The translation process actually begins with the software developer (that’s me). I individually mark strings that are to be translated with a special code. These strings can then be automatically extracted from the source code. During this process, I ensure that I mark whole sentences or paragraphs as individual words are not easily translated due to differences in plurality, word position and so on.

The next step for me is to create a special translation text file called a POT file. The POT file can be found in the plugin directory or in the downloaded plugin ZIP file. The POT file is basically an export of all hard coded strings that I have marked.

The POT file is then edited by you to include the translated strings. The POT file can be edited directly using a text editor, however I recommend installing the cross-platform GUI editor called POEdit. This makes life a lot easier and also generates MO files (see below).

To translate a plugin, you must simply include a translated string for each original string within the POT file. The POT file is then saved as a PO file (a PO file is simply a POT file that contains translations).

In some cases, the POT file contains a PHP date format. Information on how this string is formulated can be found here.

To test the translation file, you first need to save the PO file from within POEdit. This will automatically create a MO file. MO files are optimized machine readable PO files. Rename the MO file to “yyy-aaa_BBB.mo” where:

  • yyy is the name of the plugin translation file. For the Table of Contents Creator plugin, this will be “tocc”. For iRobots.txt SEO plugin, this will be “irseo”.
  • aaa is the language code. Language codes can be found here.
  • BBB is the country code. Country codes can be found here. Note that country codes are represented using uppercase characters.

An example of an Italian translation MO file for the Table of Contents Creator plugin is: tocc-it_IT.mo

The final step is to copy the MO file into the plugin directory. The recommended way of doing this is to download the plugin in ZIP form from the appropriate plugin home page and repacking it to include your MO file in the root directory. Then in WordPress deactivate and delete the existing plugin and select Add New and then pick the option to upload from a ZIP file. Browse to the modified ZIP, install and activate. Note that deleting the existing plugin will remove the default values for all options. When you reactivate the plugin, the default values will be replaced with your language specific default values.

Your translated file should begin to work immediately if WordPress is set to use the chosen language (ie you selected Italian when you installed WordPress). If it is not, there’s info on enabling non-english languages here.

Once your translation is complete and you are happy for me to include it in the next release, please email the following:

  • The translated PO file.
  • The MO file (I can create this from the PO file if you did not install POEdit).
  • The exact wording of how you wish your name to be displayed in the acknowledgement section and the URL of your website to which your name will be linked. Note that I acknowledge all translators on the plugin home page, in the plugin settings panel and in the plugin readme.txt file. You may opt out of the acknowledgement if you wish to remain anonymous.
  • Indication of whether or not I can contact you prior to future releases of the plugin. From time to time new features and options are added to the plugin. Generally only a few new options are added at a time and I will merge the previous translation with the new POT file so that the new strings need only be converted.

If you need to know more, please do not hesitate to contact me or leave a message below.

Thank you for taking interest.

Leave a Reply


SpinChimp Leaderboard 728x90