Theme and Plugins Localization
Before going to read the texts below, you can see our video tutorial:
WPML allows to create translations for texts in themes and plugins in two ways:
- Don’t use String Translation to translate the theme and plugins (translating using the traditional .mo files).
It’s good when you already have a theme with the translations you need.
- Translating theme and plugin texts using WPML’s String Translation
This setting is located in WPML->Theme and plugins localization.
Themes and plugins load their .mo files with translations, without you having to do anything. No matter what you choose in WPML’s translation options, the theme will always load its built-in translation.
When you select Don’t use String Translation to translate the theme and plugins, you simply tell WPML not to allow editing these translations using the String Translation module.
Translating the theme and plugins using WPML’s String Translation
Note: this option requires WPML’s String Translation module, available as part of the Multilingual CMS package.
Select Translate the theme and plugins using WPML’s String Translation, to manage translating texts from theme/plugin template files via WPML’s String Translation admin screen.
With this option selected, 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.
Worth noting here is that Translate the theme and plugins using WPML’s String Translation will fall back to .mo file translations if those exist in your theme and plugins. This means that if you see a translated text string in your site which does not seem to appear under String Translation, it is very likely that the translation comes from an .mo file in you theme or plugin.
Scanning the theme for strings
Click on Scan the theme for strings and WPML will go through all the files in the active theme to extract translatable texts from them (texts that are wrapped with gettext functions).
If you select the check-box Load translations if found in the .mo files, WPML will look for and load any translations provided by theme’s .mo files. These translations can serve as initial text translations which you can easily edit later if you like via WPML’s String Translation.
The scanner 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 admin page, where you can translate each individual text string found in the theme.
You will also notice a second check-box in this section to Automatically use theme or plugin text domains, when gettext calls does not use a string literal. This option might be helpful if you are using a theme which uses gettext incorrectly.
Scanning plugins for strings
Similarly to scanning a theme for strings, WPML can scan plugins and find translatable strings.
Select the plugins to scan, select Load translations if found in the .mo files if you want to use the initial translations provided in .mo files and click on Scan the selected plugins for strings.
Translating the strings
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 local translators (available in WPML >= 2.3.0) or professional translation service (available in WPML >= 3.2)
Choose the strings to translate, the languages to translate them into and click on the button to Add to translation basket.
Your local translators will be able to access the String Translation screen and translate just the ones that you’ve sent them for translation.
A locale is a code which determines which language variant to use for different languages. It’s comprised of a language/country combination.
For example ‘en_US’ means American (USA) English and ‘en_GB’ means English used in the UK.
The locales table in WPML is already pre-populated with the correct values for all popular languages. You should edit it only if you want to use a different language/country combination or if you’ve added your custom languages. For instance, the default locale for Spanish is ‘es_ES’ (for Spain), but you can change it to Mexican Spanish by setting the Spanish locale to ‘es_MX’.
To edit the locales, go to WPML > Languages > Section “Site Languages” > Click on the link “Edit Languages” and change them.
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.
* Note: In the case you experience 502 Bad Gateway errors when downloading translations, please check your server (Apache, Nginx and etc) log and if “mod_security” is disabled.
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, go to the WordPress localization project.
Choose the WordPress version that you are using, select the language and click on export to download the translation.
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 or wp-content/languages. The download links are provided in the table above (click on the language name).