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

33 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?

  5. Lee Graham says:

    Im using the Hybrid Theme Framework, anyone know how I can find out the “TextDomain”?

    thank you

  6. Urmas says:

    Hi!

    I have a problem- WPML finds only 2 strings to translate, although the theme files consists a lot more to be translated.

    How to fix that?

    • amir says:

      All the texts in the theme need to be wrapped in gettext cals and have a textdomain argument (that’s the 2nd argument in the call).

      If you’ve done that and it’s still not working, use the forum for support.

  7. Urmas says:

    Now I have found about 60 but those are not the strings that i was expecting to be.
    http://www.lexusfoorum.net/web5/

    For example that “Feature video” is generated from the text (which I can change) from sidebar.php file but WPML does not but that to the list.

    The other thing is that do I really need mo files for every language? I mean- what do they includes? WordPress default strings I guess?

  8. Ivan says:

    Hi,

    I try to translate the “Homepage Box # ” on my homapge, but they still don’t appear on the string ?
    How can I get an access to these box?

    Thanks
    Ivan

  9. tico says:

    Thanks for the plugin!!!

    I currently have a dynamic website in the following setup.
    http://www.example.com/en
    http://www.example.com/es
    http://www.example.com/fr

    I want to install a blog like
    http://www.example.com/en/blog for English,
    http://www.example.com/es/blog for Spanish, and
    http://www.example.com/fr/blog for french

    What is the best way to accomplish this in the plugin.

    • amir says:

      I don’t think that you can achieve this with WPML.

      You can get example.com/blog/es/, but not the other way around.

  10. Sébastien says:

    I’ve installed a theme that use lot of options stored in database. How can I translate these options ?

    • amir says:

      Hold on for WPML 1.7.3. It will include an interface for translating admin texts. As always, we’ll be announcing it in our blog.

  11. Artyom says:

    Hello!
    WPML is very nice! Thank you for this plugin. But I need some help. When Im changing language of a page, it translating, but I cant see another pages. only Home page. Maybe because of my theme? it is Basic theme designed by ElegantTheme and even when Im adding page on my native language I need to set up in theme options to show this new page on the site. But when Im adding translation of this page I cant see it in the Theme options.
    Thank u for help

    • Bilal says:

      Hi,

      Im dealing with the same problem..I’ve to select the pages for nav menu from my themes options panel. But it displays only the default language pages. Is there a way to fix this..

      Thanks a lot..

  12. Zenia says:

    Hi, I just wanted to know how could I translate words in php files with this plugin, is that possible? Example in my site (http://justfm.lt) im my header.php i done navigation.

  13. Artyom says:

    amir, help me please.
    When Im changing language of a page, it translating, but I cant see another pages. only Home page. Maybe because of my theme? it is Basic theme designed by ElegantTheme and even when Im adding page on my native language I need to set up in theme options to show this new page on the site. But when Im adding translation of this page I cant see it in the Theme options.

  14. tankjer says:

    I have an English theme and it tries to translate not to polish, but to English… What could be wrong? I’m using P2 theme.

  15. Ricardo Amaral says:

    I think I have the same (or similar) problem as above…

    My blog default language is Portuguese (PT) and then I have English (EN) as secondary. On the theme’s root folder of the theme I’m using, there’s a folder named “languages”, which has .mo/.po files for PT language (but there isn’t one for EN). However, the PT translation is not complete, there’s about 18 strings missing in the .mo/.po file and I find easier to just translate this on the WP admin instead of messing with the files.

    But there’s a problem… When I translate the missing strings with WPML, they are actually being replaced on the EN language and not on the PT one. The PT one will actually use the default EN strings instead of using the PT ones I just translated using WPML.

    How can I fix this issue?

    • Xavi Ivars says:

      I’ve got exactly the same problem: WMPL uses default language configured at its options as default language for gettext calls, and it wouldn’t be the same (as templates are usually in English by default).

  16. ashty2 says:

    How can I translate links in my sidebar or some text in vidjets?

  17. Gabriel says:

    One text that is wrapped with gettext is not being displayed for translation.
    How should it be wrapped for WPML to find it?

    Right now it’s:

    Thanks,
    Gabriel

  18. Luca says:

    I think this is the future of Multi language Plugin! Thank you for this great job!
    Just two questions.

    1. I use a theme that includes a slider for post. In my default language (IT) everything works properly, but when I use the footer switcher, the slider disappears.

    I got this both in [http://example.com/ - Italiano, http://example.com/en/ - Inglese, etc.] and in [http://example/?lang=en] configuration.

    2. Dropdown menu in header bar doesn’t work and shows just the mother page, and not the sons.

    I think these two problem are generated by the same cause, but I don’t know what! :-)

    Any idea of solution?

    Thank you in advance,
    Luca

    • amir says:

      We’re going to be ready with the next version of WPML early next week. Let’s see if it works after that change.

      Then, if not, we might be able to check this for you as a paid service. Let me know if so, and I’ll connect you with some very capable support folks.

  19. Luca says:

    Thanks! I hope it will work! :-)
    Luca

  20. Blackbam says:

    Thank you for the great plugin, i was thinking for quite a while if i should use qTranslate or WPML and decided to use WPML for future projects, because it can translate really all strings, seams to be more professional, faster and has better SEO and content seperation.

    Though there are some things that I miss:

    - WPML can not automatically detect the users language, at least in my test that did not work (using always default language on the home page)

    - it is not possible just tu display posts which is not translated in their original language with an note that it was not translated automatically (which a also liked with qTranslate)

    - i had a german theme, which i prepared for localization, but i can not change the default theme language in WPML, it is always en-US and i can not point to an en-US.mo language file to use

    Maybe I am just to stupid to handle it, but maybe it is also something you could fix in future versions?

  21. horia says:

    I installed the WPML plugin on a site, it works great, thank you!
    I would like to translate some words from an english menu (from the theme) to another language. But as these words are just plain html in the theme, they are not automatically translateable. I would need to make them strings.

    As I read here, I need a “gettext” system, with which i would insert text strings via php in the theme. These text strings would be then recognisable by the WPML plugin and the plugin would be able to change these strings for each languages.

    But, my problem is, I cannot find a good gettext explanation, for people who do not use php. Would you be so kind and give us a simple example here?

    Thanks a lot!
    Horia

  22. horia says:

    Gettext:
    In the meantime I found the answer myself, and I post here a simple example, If anyone needs it:

    instead of a text like: “Main Menu” like this:
    Main Menu

    you insert this:

    (where “your theme” is the name of the theme that is used, if the case)

    this makes WPML able to find the string “Main Menu” and to ask you then for translating it in another language of your WPML enabled site.

    more details here, a great blog post about it:
    http://blog-en.icanlocalize.com/installing-wordpress-for-multiple-language-blogs/how-to-localize-wordpress-themes-and-plugins-with-gettext/

  23. horia says:

    Gettext:

    this is the same answer again, hoping that the code will show this time!

    In the meantime I found the answer myself, and I post here a simple example, If anyone needs it:

    instead of a text like: “Main Menu” like this:
    Main Menu

    you insert this:

    (where “your theme” is the name of the theme that is used, if the case)

    this makes WPML able to find the string “Main Menu” and to ask you then for translating it in another language of your WPML enabled site.

    more details here, a great blog post about it:
    http://blog-en.icanlocalize.com/installing-wordpress-for-multiple-language-blogs/how-to-localize-wordpress-themes-and-plugins-with-gettext/

  24. horia says:

    Gettext:

    this is the same answer again, hoping that the code will show this time!

    In the meantime I found the answer myself, and I post here a simple example, If anyone needs it:

    instead of a text like: “Main Menu” like this:
    <h2 class=”menuheader”>Main Menu</h2>

    you insert this:
    <h2 class=”menuheader”><?php _e(‘Main Menu’, ‘your theme’); ?></h2>

    (where “your theme” is the name of the theme that is used, if the case)

    this makes WPML able to find the string “Main Menu” and to ask you then for translating it in another language of your WPML enabled site.

    more details here, a great blog post about it:
    http://blog-en.icanlocalize.com/installing-wordpress-for-multiple-language-blogs/how-to-localize-wordpress-themes-and-plugins-with-gettext/

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="">

Subscribe without commenting