There are a number of variations of these functions, as well as ones specialized for use with HTML attribute values for instance. Another one is _n('message', 'plural', $number) which is used to retrieve the singular or plural form of a string, based on the amount $number. Some additional useful functions to know include _x('message', 'context') which allows you to provide some context information for translators to provide them with additional comments needed to distinguish between the same word used in different contexts, for instance. While coding a plugin or theme it’s always good practice to use the special (and odd looking) localization functions whenever displaying text, with the two most common being: _('message') and _e('message'). Place the MO file into the directory within your plugin that you specify in your call to load_plugin_textdomain(), ie “languages”.Provide the POT file to a translator who returns one or more PO files with the text translated.Extract all translatable strings into a POT file.Include a call to load_plugin_textdomain() as I describe in my article Writing a Plugin That Can Be Localized by WPML.
Code the plugin/theme using the translation functions _('message'), _e('message'), etc.The basic process for translating a plugin or theme is as follows: Extracting Strings for TranslationĪlthough I won’t delve deeply into all aspects of WordPress internationalization (i18n), it is important to note that it’s built on the excellent GNU gettext localization framework. The codex article might be better if you’re translating a plugin that you have listed on, but since the majority of my plugins are either custom for a client or myself, or listed in the WooCommerce shop, I have to do my translation on the command line. Although this is documented in the codex: I18N for WordPress Developers and Translating WordPress, those articles are somewhat lengthy and the first time I was asked to internationalize a plugin it took me some time to find the actual steps to generate my POT file. The purpose of this article is to provide a quick and easy to follow step-by-step guide to extracting text strings from a WordPress plugin for translation from the command line. You can either use FTP to upload the file or log in to your WordPress and upload it by going to Plugins > Add Plugin.
Now that MEC is translated, you can upload it (of course, first you need to zip it again). mo files in your plugin’s language folder.ħ. When you’ve finished translating, simply save your file. Below it, there is a table where the source text is on the left and the target text on the right.Ħ. On top, you will see the translatable file. Now we can start translating MEC. Poedit provides a simple and straightforward interface that does not involve a steep learning curve. Now, you need to save your file in the languages folder of your plugin.ĥ. Note: If you use the Modern Events Calendar Lite version, the name structure is: modern-events-calendar-lite-fr_FR.po and modern-events-calendar-lite-fr_FR.mo For example, if you’re translating Chinese to French, the file should be named “mec-fr_FR.po” ( mec for MEC plugin, fr for the language, and FR for the country.) The name is important because there’s a particular format you should follow for consistency. After you hit OK, you’ll be asked to name your translation file. Enter the language you want to translate here along with any other required details.Ĥ. A catalog property box will open asking for information about what you are translating. Open Poedit and go to File > New Catalog from the POT file.ģ.
It also provides localization tools for developers, such as extracting strings and generating templates.Ģ. Loco Translate provides in-browser editing of WordPress translation files. You can translate MEC on your site (online) with “Loco Translate” plugin. Poedit is a free, easy-to-use, and open source program for Mac, Windows, and UNIX/Linux for editing PO files and generating MO files. The tools available are GlotPress, Launchpad, and Pootle, but we’re going to use Poedit. You can translate MEC plugin with four available tools.