Internationalization: GNU GetText or Google Translate

If you are a WordPress theme or plugin developer, you may have heard of the internationalization (i18n) and localization tools available so that your plugins and themes can reach the widest global user base. They use the famous GNU gettext functions to do the actual work of maintaining translations of strings and providing the right string to the end user depending on his locale. This method works extremely well, but it has some drawbacks.

  • You have to depend on friendly international users to provide you the translation strings.
  • You have to maintain the translated strings in your codebase.
  • Most annoyingly, you have to write your PHP/HTML code using the gettext functions (__() and _e() to begin with), which make the code ugly.

I have over 20 plugins that I actively maintain for the WordPress community, and the effort of collecting, collating and maintaining the translations was beginning to overwhelm me. I wrote my own translation interface (called easy-translator) and embedded it with my plugins so that my international users will have an option to provide or improve translations. I also refactored my plugins to the extent possible so that the duplication of the translation and maintenance effort would be a minimum. Still, the constant stream of .po files coming in and the need to release them in a timely fashion was actually beginning to take a toll.

Over the last few years, the quality of machine translation has improved a lot, especially when it comes to European languages. So recently, I decided to kill my gettext .po and .mo files and provide and easy interface to Google Translate instead. I have written refactored code to provide a neat Google Translate menu item in all my plugins, with the language defaulting to the end user’s locale if it is not English. In the next post, I will share the functions I use, along with the styles so that you can easily internationalize your plugins or themes as well.

Note that machine translation is not as good as good human contribution. But it is improving, and the difference as of now is not probably worth the extra effort you have to put in to maintain and provide human translation. Besides, machine translation lets you write the PHP/HTML code beautifully, without dropping php tags and __() functions all over the place, which may improve the performance of your server a little bit. At the very least, it will let you concentrate on you what you do best – writing code!