i18n Internationalization and Translation for plugins

Until a few days ago, I would never have envisioned to write a posting about i18n in WordPress… And then I started the task to make my plugins ready for translation by the community at translate.wordpress.org.

i18n stands for internationalization = I + 18 charachters + N

While working my way through the principles and standards to use, I realized that there are quite some things you should consider and have to do in a certain way – let me touch some of them over a few posts…

1) In general: Where and how to maintain the translation files?

You can store them “locally” together with your plugin repository. But this means some major work maintaining translations – new strings, changing ones, new language submissions, etc.

For the majority of plugins, the separate repository at translate.wordpress.org should be a good and sufficient place to maintain their language packs. It offers all users an easy way to contribute translations for individual strings – and the plugin authors an easy way to maintain latest versions for including with the plugins.

2) Development: How to make it work? What is going wrong?

The description in the development documentation for plugin says, it’s very easy…basically call “load_plugin_textdomain” and upon commit to the repositories, your plugin automatically gets uploaded into the translation repository.

But somehow it wasn’t easy. Opening the translation repository for my plugin th23 User Management showed an error message, whatever I tried…

This plugin is not properly prepared for localization. If you would like to translate this plugin, please contact the author.

Now you can try around a thousand ideas, guessing what you might have done wrong…just as I did, because the error message is not “very specific” – or you know, where to find more detailed information. Unfortunately it is well “hidden” *smiley annoyed*

Go to the WordPress channel on Slack and join the channel “#meta-language-packs”.

In this channel, search for your plugin PHP file, eg for mine “th23-user-management.php” and there you find some more information (see the part in red below) with hints on what you do wrong:

Plugin Imports BOT [21:51]
 Import of th23-user-management
 ​_Time: Mon, 25 Jan 2016 20:50:49 +0000, Development Log_​
 Code for stable (th23-user-management/tags/2.2.0/) in process...
 This plugin has a wrong text domain declaration in the file header:
 `./th23-user-management.php:Text Domain: th23_user_management`
 Code for stable was processed.
 Readme for stable (th23-user-management/tags/2.2.0/) in process...
 The GlotPress projects were updated.
 Result of the POT import: 63 new strings added, 0 updated, 0 fuzzied, and 0 obsoleted.
 Readme for stable was processed.

Thanks to the WordPress team, there is also now a hint in the i18n FAQ for plugin developers – look at the very bottom.

Leave a Reply