WPML enables you to translate the texts coming from themes and plugins you use in your sites. This allows you to have a completely translated site. Additionally, it allows the users of your site’s administration area to use the interface in their native language.
Localization options and performance optimization
You can find the settings for theme and plugins localization on the WPML -> Theme and plugins localization page.
WPML allows you to create translations for texts in themes and plugins in three ways:
- Use only String Translation.
- Use String Translation but load .mo files as a backup.
- Don’t use String Translation but only load the .mo files. This is a good option when you already have a theme with the translations you need.
Theme and plugins localization options can significantly impact the performance of your site. WPML version 3.8 and later automatically suggests the most efficient localization options.
By default, it prompts you to use WPML’s String Translation only, by loading all the translations from the .mo files into the database. This importing is done once and after it is complete (it can take a while, depending on your site), the performance will be optimal in regards to theme and plugins localization.
Finally, String Translation warns you once this process has finished.
Translating the theme and plugins using WPML’s String Translation
As we already mentioned, when using String Translation to translate the theme and plugins texts, you can select to load the .mo files as a backup or not.
When loading the .mo file as a backup is selected, WPML 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 a .mo file in your theme or plugin.
When either of these options is used, WPML scans the theme and finds the texts that can be translated. It reports what it finds and let you enter translations, right from within WordPress.
Since version 3.8 and later, by default, WPML automatically prompts you to scan for new texts in your site whenever a theme or a plugin is activated.
Scanning themes for texts
You can also manually start the scanning of themes for texts. Select the themes to scan and click on Scan selected themes for strings. WPML goes through all the files in the selected themes to extract translatable texts from them (texts that are wrapped with gettext functions).
The scanner shows how many strings were found in the theme and their translation status. You can translate them from the WPML -> String Translation page.
In the Localization options section, under Other options, you can find an option to Use theme or plugin text domains when gettext calls do not use a string literal. This option might be helpful if you are using a theme which uses gettext incorrectly.
Scanning plugins for texts
Similarly to scanning a theme for strings, WPML can scan plugins and find translatable strings.
Select the plugins to scan and click on Scan selected plugins for strings.
Translating the strings
Administrators and Editors can translate theme and plugins texts on the WPML -> String Translation page.
To translate a text, use the search controls on the top of the page to filter the specific strings. Most importantly, select the domain (it should feature a theme or plugin’s name) whose texts you want to display and translate.
To manually translate listed texts, click the translations link for the text in question, enter the translation, select the Translation is complete checkbox and click Save. If you see translations of the text in question, marked in yellow, this is the translation coming from the theme or plugin’s .mo files. If you prefer, you can override them with your own, by selecting the Use my translation option and providing the translation in question.
You can also assign the selected texts and send them for translation by your designated local translators or professional translation service. For this, you need to have the WPML Translation Management module installed on your site.
Choose the strings to translate, the languages to translate them into and click on the button to Add to translation basket.
From the Translation Basket tab of the WPML -> Translation Management page, you will then be able to select the translator and send the selected texts for translation.
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 is comprised of a combination of language and country.
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 have 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 the WPML -> Languages page and click the Edit Languages link found in the Site Languages section.
Getting Translation Files for WordPress Itself
In the past, you needed to use the Theme and plugins localization page to download the translations of WordPress core files.
Now, WPML does this automatically any time you add a language on the WPML -> Languages page or during WPML installation.