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

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.

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 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
Traditional Chinese zh_CN China
Simplified Chinese zh_HK Hong Kong
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).

6 Responses to “Theme localization”

  1. Adam Chan says:

    Thx for the plugin!!! It’s been really useful!!

    I think you should have a link to this post. It makes much more sense about text domain and text wrapping. It took me some time to figure that out.

    By the way, simplified Chinese is used in China, and traditional Chinese is used in Hong Kong and Taiwan. You got it another way round.

  2. Markus says:

    Yes, this sounds amazing…

    just a quick question:
    What is the concept for multiligual support of plugins?

    Thanks

    Markus

    • amir says:

      Right now, WPML doesn’t localize plugins (yet), so you still need to use the .mo files for that. We’re planning to add this soon, but I can’t give an exact date.

  3. There’s no voice like “WPML->Theme localization” in the plugin menu :(

  4. Fahdos says:

    is there any way to shose a theme for a selected language? for exemple if defaut language > use the EN-theme if arabic then use the AR-theme ( where ( AR-theme is the name of the wordpress theme )?? any idea?

Leave a Reply

Please leave here comments about this page only.
For technical support and feature suggestions, head to our forum. We are waiting there!

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">