ZyBlog

WordPress, Web Development, SEO and more

Localizing WordPress Themes

Note: This is a translation of my post WordPress Themes lokalisieren. Thanks to Ainslie Johnson for reviewing my translation.

A few days ago the WP-Andreas09 theme for wordpress became available. This is based on a design by Andreas Viklund, Ainslie Johnson did a very good job of converting it for wordpress.

Unfortunately the language used inside the templates was English, as it is for most themes available. To make a translation you need to go through each template file, find the English words and translate one by one.

In wordpress itself, localization is done by .po/.mo files. Hence there are localization files for a number of languages already. All you have to do, is to copy this file to your directory, change a parameter and wordpress can speak a new language.

So, why not use this mechanism for themes? There are very few existing themes working this way. More precisely, I only know of two Giraffe and NIkynik Blue. Even then, I was unable to find detailed documentation on how these themes were built.

Theme localization is very easy to do, when you manage to understand how wordpress and gettext work together.

Gefällt dir der Beitrag? Dann teile ihn!

48 Kommentare

  1. Thank you for this great tutorial. Only one question is still unanswered for me: If i do a translation / localization and then change line numbers by modifying the code, does this have any impact on the translated output?

  2. No this has no impact on the output.
    If you change the templates an leave all _e() and __() functions unchanged, then everything sould be fine.
    The identifiers for the translation are the texts within the _e() & __() functions. So if you change _e(‚Not Found‘) to _e(‚Nothing Found‘) the translation will not be working any more for this particular text.

  3. Hi! Can I ask a newbie question?!
    I did not know about the proper ways of translating themes and I simply translated the php files.
    Now that I saw .pot files I am a bit confused.
    Can I simply translate text in the pot file?? WHat else do I need to do?? Cuz I did, and I don’t see any change. How should I implement the translated pot file??

  4. Hi Milad,

    I think your questions are already answered in my article above.

    You can’t just translate the pot file. You need the .pot file and translate it with some editor like poEdit. Then you can create the .mo file. This file will be dropped in your theme directory. If the language settings are right, your theme should now be translated.

    Make sure that you read all three pages (Seiten) of my tutorial.

  5. Pingback: Tilrettelegge temaer og innstikk for oversettelse | Norsk WP

  6. Thanks for the nice tutorial. I intend to translate theme vidiyal (http://themecorp.com/themes/vidiyal/), which is already quite ready for translation (ie, with lines like < ?php edit_post_link(__('Edit This
    ')); ?>
    )

    But as you can see, there is no domain in this case, neither is there a call to load_theme_textdomain(), so how am I supposed to do?

    Another point: http://www.poedit.org/ seems kind of down, but http://www.poedit.net/ is OK.

  7. Hi Mll,

    I think the vidiyal theme uses the default wordpress strings, so if there is the „official“ string of „Edit This < br / >“ it should be translated inside the theme too.

    So if you use a localized version of wordpress, the theme should show translated strings. If it doesn’t, I advise you to change all _e() and __() functions and add a domain to the function call.
    Therefore you can create your own translation an make sure the strings are translated as you want them to be.

    Thanks for the updated poedit link. I changed it in my post.

  8. I am myself surprised how few templates are multilanguage ready.

    Using Gengo plug-in (multi-language plugin) and with your tutorial, i was able to make an (almost) perfect translation of the template blog.txt (aka blogtxt) and display in two languages!

    thx for the tutorial.

  9. Thank you for your feedback Kim.
    It’s always good to know that my posts are helpful to others.

  10. Pingback: CopyBlogger Theme - The localizable and the German Version » Marnems Sicht der Dinge

  11. Hallo! Any idea why my php template files do not show up in the poEdit „update from source“ menu? I’m growing rather desperate… after tagging all the _e and __ , there must be something I’ve done wrong. I’ll be grateful for any help.

  12. Hi Paola,

    did you set all your paths correct? As my poEdit shows all menu entries in german language, the following might be not perfectly correct:

    In the menu dialog

    Catalog / Options / Paths

    The base path must be the directory of your theme/templates.
    The list of paths below must contain „.“ (a single dot).

    Hopefully this will solve your problem.

  13. Pingback: Weblog Tools Collection » Blog Archive » Localizing a WordPress Plugin Using poEdit

  14. Pingback: 新建一个 » Blog Archive » 使用 poEdit 本地化 WordPress 插件

  15. Pingback: My favorite WordPress Resources | sebthom.de

  16. I have uploaded both Mocha and Gengo into my wp plugin folder, but when I have activated them in the wp-admin plugin page they have „disappeared“ from the list, also if they are still present in the folder.
    I have deleted them from the folder and uploaded again, but nothing happens.
    Some suggestions?

    Thanks

  17. Hi Lorenzo,

    what is Mocha and Gengo?

  18. Dear Tim,
    I am using the Blue Zinfandel theme in my WordPress weblog. I would like to ask you to check it if it is possible to translate it into Hungarian the way you have described above.
    Thanks!

    Laci

  19. Hi Laci,

    I had a quick look at the Blue Zinfandel theme. As it seems to be a standard wordpress theme, I think it should be possible to localize the theme without problems.
    In fact, it should be possible to localize any wordpress theme, as the method to do this is based on standard techniques used by wordpress itself.

    Tim

  20. Pingback: Tłumaczenie skórki | Migol's Blog

  21. Pingback: 使用 poEdit 本地化 WordPress 插件 at 第七封印

  22. Thanks a lot!!!
    It was about 4 hours I was searching for a solution!
    It now works very well.
    I’m webdesigner and was a newb about translations in WordPress.
    I edited the french WordPress version (2.6.1) and based my theme on kubrick’s french version
    which had .pot, .po and .mo files in the folder.
    I first copied the folder and modified all the files and codes to fit my design
    but couldn’t understand why the po and mo files wouldn’t work even after renaming it… hehe 🙂
    Now i understand that the path is inside the file and the the .po is just a source file to generate the .mo as you save. (the .pot a kind of structure that was useless for me as i had already the almost correct translation in the .po)
    So if someone read this comment and just need to make his own theme based on an existing theme with .po and .mo files (which is quite faster to release) you just need to use a .po file editor and change the path as it is explained in the tutorial (i also changed the name of the file as „fr_FR“ and change the „domain“ in my php files).
    For mac users you can get the path of your folder by „CMD+i“ it 🙂
    (you can’t copy-paste it but it doesn’t take that much time to write…)
    Thanks again.

  23. Pingback: Wordpress auf die Schnelle mehrsprachig machen - Peter Kröner - Die Kunst des Machbaren

  24. Pingback: Spolszczenia szablonów - prawie 150 przetłumaczonych skórek do pobrania

  25. Pingback: Wordpress Magazine Theme Released | Darren Hoyt Dot Com

  26. Pingback: Mimbo 3.0 Released | Darren Hoyt Dot Com

  27. Pingback: WordPress Watch » Blog Archive » Darren Hoyt releases Mimbo 3.0 - WordPress magazine style theme

  28. Pingback: Mimbo v3.0 | WP Magic Themes

  29. Pingback: q2w3.ru » Локализация шаблонов (тем) WordPress.

  30. Thank you for this great tutorial. You solved the problem in no time! Excelent! Now all my new themes will use this method, so anyone will be able to translate it easly.

    Thanks again!!!! Very very very much!!!

  31. I am having trouble localizing Carrington Mobile. That is: a plugin and a theme. I managed to translate Carrington Mobile theme and plugin. At least almost. There are still some words here and there which didn’t appear on the poEdit.

    For example:
    „about“, „more →“, „Return to the Mobile Edition“, „Categories: Uncategorized“
    are still untranslated. Any suggestions?

    It appears there are two project names: “carrington” and “carrington-mobile”. So, I should make two sets of .po and .mo files. Am I missing something? Where should I put the different files or should I somehow merge them? And how is this possible?

    http://wordpress.org/extend/plugins/wordpress-mobile-edition/
    http://wordpress.org/extend/themes/carrington-mobile

  32. sorry i am a newbie, i have mimbo pro 2, which allready been translated as far as i have understood to many languges (as i can see language files in the .po and the .mo files for Dutch language, but what is next?
    i have tried putting the nl_NL.mo as well as the nl_NL.po
    in the theme drictory but nothing changed

    i also have inserted

    intio the header, but no luck

    am i missing any thing here?

    regards

  33. Pingback: Mimbo theme configuration | PAGCOR Parañaque Portal

  34. Pingback: Green Park 2 Beta 5 pre – for translators only | Cordobo

  35. Pingback: Green Park 2 Beta 5 pre – for translators | Word Press Magazine

  36. Pingback: Počeštění šablony pro Wordpress - Radoviny.net

  37. Pingback: 使用 poEdit 本地化 WordPress 插件

  38. Pingback: Leo Arias (elopio) 's status on Friday, 09-Oct-09 00:59:44 UTC - Identi.ca

  39. Has anybody had any success localizing the Mimbo Theme using this method? I have tried to localize it to spanish (es_ES) following all the steps with no success…

  40. Just wanted to say thanks for your article. I got everything right except the domain part… But now I know how it works!

    Cheers

  41. Thanks – Danke!

  42. Danke für das tolle Tutorial. WordPress ist und bleibt einfach interessant!

  43. That’s good explanation, thanks for the lesson very much. have mention it in my post

  44. Danke, merci and thanks a million. I have been wandering in the desert of wordpress php code dunes for hours trying to figure how to get my theme header to display blog title and tagline (description) in the language of the rest of the page on a bilingual wordpress site I am doing for a customer.

    Your excellent article gave me the key, …how simple it was…but as they says it’s easy if you kno.
    Now everything including the header switches languages at will. Have a beer on me! 🙂

    I totally agree with your suggestion. The template I used, called dialogue, was described as „translation-ready“, yet hundreds of texts were hard.coded in German, texts that already have a standard string in wordpress so there was no need to leave it hard coded.

    Templaters should definitely use functions instead of hard code everywhere. Then we multi.linguists would have alot more template choices and less hair pulling !

  45. Hi,

    ich mache alles genau so wie du es schreibst:

    catalog options:

    basepath: absolute path to the theme directory on the harddisk
    paths: . (only the dot)

    Allerdings bekomme ich ständig die Fehlermeldung, dass es angeblich keine Dateien zum Durchsuchen gäbe. Das ist nicht korrekt. Wenn ich allerdings, wie einige andere der spärlichen Quellen zu dem Thema das empfehlen, als weiteren Pfad „..“ angebe, dann erhalte ich gleich mal gut 4000 übersetzbare Elemente. Ich nehme an, dass Poedit, dann einfach auch noch andere Ordner durchsucht, wo ich Theme-Dateien abgelegt habe.

    Jetzt wollte ich aber erstmal nur testen, ob das ganze ÜBERHAUPT funktioniert, weshalb ich nur eine vorbereitete php-Datei parsen wollte: Nämlich die, die in dem entsprechenden Theme-Ordner enthalten ist.

    Hast du irgendeine Idee?

    Bye

    Ali

  46. Pingback: Nguyễn Đức Ban | Đa ngôn ngữ với Wordpress

  47. Bei Ali Schwarzers Problem kann ich leider nicht weiterhelfen. Die Einstellungen sind richtig. Evtl. ist der Pfad zu den Dateien nicht richtig?

  48. Thanks a lot for this – i’d been going round in circles trying to translate a Spanish page into French for a client. I’m using WPML but their insctructions are not too clear.

    I was missing the line:

    You’ve saved me from losing the plot. Thanks for that 🙂