Localizing Wordpress Themes

Seiten: 1 2 3

Anzeige

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.

Bookmarken bei Diese Icons verlinken auf Bookmark Dienste bei denen Nutzer neue Inhalte finden und mit anderen teilen können.
  • MisterWong
  • Y!GG
  • Webnews
  • Linkarena
  • Oneview
  • Tausendreporter
  • SEOigg
  • Digg
  • del.icio.us
  • StumbleUpon
  • Folkd
  • Furl

Ähnliche Artikel
  1. Wordpress Themes lokalisieren
  2. Deutsche Sprachdatei für Wordpress Theme WP-Multiflex-3
  3. Deutsche Sprachdatei für Wordpress Theme Chameleon
  4. Deutsche Sprachdatei für Wordpress Theme Ebony
  5. Norwegian nynorsk localization for Wordpress theme “wp-andreas-09 l10n”

20 Pingbacks / Trackbacks

20 Kommentare zu „Localizing Wordpress Themes“

  1. Ralph sagt:

    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. Tim sagt:

    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. Milad sagt:

    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. Tim sagt:

    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. mll sagt:

    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.

  6. Tim sagt:

    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.

  7. Kim sagt:

    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.

  8. Tim sagt:

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

  9. Paola sagt:

    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.

  10. Tim sagt:

    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.

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

  12. Tim sagt:

    Hi Lorenzo,

    what is Mocha and Gengo?

  13. Laci sagt:

    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

  14. Tim sagt:

    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

  15. Mickael sagt:

    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.

  16. Rics sagt:

    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!!!

  17. Martti sagt:

    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

  18. Alexq sagt:

    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

  19. igor sagt:

    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…

  20. Jeremy sagt:

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

    Cheers

Kommentieren

Sie können diese HTML Elemente nutzen:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>