Internationalizing or Localizing Your Plugin

WordPress users exist across the United States, Russia, Japan, Germany, and all points in between. Therefore, the next person to download and use your plugin may not speak the same language you do. So if you wrote and distributed your plugin in English, it may be useless to the next person to download it if he only speaks German. However, the WordPress software has internationalization built into it, which means it can be localized, or translated, into different languages.

image You aren't translating the file into different languages, unless you want to. Rather, you're providing a mechanism of support for people who will want to provide translation for your plugin through the creation of .mo (machine object) files (discussed later in this chapter). Many people in different countries create (and have created) .mo files for the translation of WordPress into different languages; by providing localization for your plugin, you're enabling them to translate your plugin text, as well. (If you're interested in translating WordPress into a different language, check out this resource page in the WordPress Codex at http://codex.wordpress.org/Translating_WordPress.)

Using GetText Functions for Text Strings

WordPress provides you with two main localization functions: __ and _e. These functions use the GetText translation utility installed on your Web ...

Get WordPress® All-in-One For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.