Localization and Internationalization

WordPress uses standard PHP gettext functions to allow string translations. To make your plugin available for translation, you have to localize all your strings.

The process of localizing strings is simple, but tedious. Each string must be wrapped in one of two functions. Echoed strings should be wrapped with _e(), while strings passed as arguments to other functions should be wrapped in __(). Additionally, each wrapper function must have a second argument, the text domain of your plugin. Most plugin authors use the directory name as the text domain. Finally, you need to generate a separate file containing all those wrapped strings, which translators will use as a template.

There are tools on WordPress Extend to help you with most of this. You'll still have to wrap the strings in the appropriate functions, but once that's done, you can automate the processes for the text domain and the language files.

■ Note: Because "internationalization" is a twenty-letter word that takes a while to type, it's often abbreviated as "i18n," with the middle 18 letters omitted. Similar abbreviations include localization (l10n) and accessibility (ally).

Was this article helpful?

0 0

Post a comment