Home » Documentation » Getting Started Guide » Theme Localization

Theme 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.

Theme localization options in WPML 1.2.0

Theme localization menu


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).

Theme localization summary after scanning for texts

Theme localization summary after scanning for texts

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.

Theme strings translation

Theme strings translation

* 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.

Specifying the locales for different languages

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.

Locale settings

Locale settings

The following table lists locale values for popular languages:

Language (links to the WordPress localization) Locale Country
German de_DE Germany
Spanish es_ES Spain
Dutch nl_NL Netherlands
Danish da_DK Danish
French fr_FR France
Italian it_IT Italy
Brazilian Portuguese pt_BR Brazil
European Portuguese pt_PT Portugal
Russian ru_RU Russia
Simplified Chinese zh_CN China
Traditional Chinese zh_TW Taiwan
Japanese ja Japan

* There are many other .mo files available through the WordPress localization project.

To enable localization for your language, you need to do two things:

  1. Set the language locale file in the Locale file name column.
  2. 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).