Theme and Plugins Localization
WPML allows localizing themes in two ways:
- The traditional .mo files (good for when you already got that with the theme).
- Translate the theme’s texts directly from WPML
This is the theme localization menu, found in WPML->Theme localization.
Providing translation for the theme texts
Option 1: Translating the theme from within WPML
Note: this option requires WPML’s String Translation module, available as part of the Multilingual CMS package.
When WPML localization is selected (the 2nd option in the image above), WPML will scan the theme and find the texts that can be translated. It reports what it finds and let you enter translations, right from within WordPress.
Click on Scan the theme for strings and WPML will go through all the files in the active theme and get translatable texts from them (texts that are wrapped with gettext functions).
It shows how many strings were found in the theme and their translation status. To translate them, click on View strings that need translation. This will take you to the String translation page, where you can enter translation for each of the texts found in the theme.
* Don’t stop here, next you need to set the locale for each language.
The String Translation screen is available to Admins and Editors. If you’re also using WPML Translation Management module, you can choose strings and assign them for translation by your designated translators (available in WPML 2.3.0 and above).
Choose the strings to translate, to which languages and click on the button to send to translation. Your translators will be able to access the String Translation screen and translate just the ones that you’ve selected.
Option 2: Using a .mo file for theme localization
Many WordPress themes already come with translations to different languages. When this is available, you can use the translation that’s already provided instead of translating yourself.
To use translation from a .mo file, choose the first option from the theme localization menu. The only thing that you need to specify is the text-domain for your theme.
When the theme was created, the texts were wrapped in gettext calls. Each call includes two arguments – the string that needs to be translated and a second argument called the text-domain. This second argument identifies all the texts in the theme as belonging to it. You need to enter this value in the text domain field, so that WPML can load the translation file and assign it to the theme.
A locale is a code which determines which language variant to use for different languages. In order for theme localization to work correctly, you need to tell WPML which locale value to use for different languages.
Getting Translation Files for WordPress Itself
Many of the texts in your site come from WordPress itself. This includes date formats, standard texts and the entire localization for the WordPress admin.
You can let WPML download these translations for you, or download and install them manually.
Option 1) Letting WPML download WordPress translations
WPML can automatically download the required translations for WordPress, for your site. This functionality requires the String Translation module. Once enabled, you’ll see an option for WPML to automatically download WordPress translations.
Follow this guide for downloading WordPress translations to see how it works.
Option 2) Downloading translations for WordPress manually
If you prefer to download the .mo files for WordPress manually, you can use this table for links to frequently-used WordPress .mo files:
|Language (links to the WordPress localization)||Locale||Country|
* There are many other .mo files available through the WordPress localization project.
To enable localization for your language, you need to do two things:
- Set the language locale file in the Locale file name column.
- Download the WordPress locale file and save it to wp-includes/languages. The download links are provided in the table above (click on the language name).
The procedure to localize plugins is similar. First, select the plugins that you want to localize and click on “scan the selected plugins for strings”:
After finishing the scan, you’ll be able to view the strings identified by WPML, and add the missing translations just as with the theme:
Once you have added missing translations, you can generate new localization files for the plugins for which you have added translations using the “Export .po” option in WPML->String Translation. Make sure you select the appropriate context and language before exporting. This comes handy if you need to reuse your translations for a reinstall or in a different site.