Connect
To Top

What it takes to internationalize a theme?

Quite often, I do get emails from people who wants a version of my theme, ported to their language. I always thought it is a cumbersome job to make the theme internationalized.
but recently my opinion got changed by a Danish guy.

Henrik from http://henrik.schack.dk/ recently contacted me asking me if it is OK to release the Danish version of MistyLook that he worked on.

I had a little chat with him over the email and this is what I learned.

Step 1: Prepare your WordPress Theme:
You have to wrap all your text within the theme, inside a

<?php _e('some text goes here', 'ml') ?>

It means if you want the sidebar’s heading to have

<h3>Pages</h3>

you should actually be coding it as

<h3><?php _e('Pages','ml'); ?></h3>.

You should do this everywhere the theme emits any text.

Next thing we have to do is, add a line in the functions.php.

<?php load_theme_textdomain('ml'); ?>

where ‘ml’ is the short form of the theme name ‘MistyLook’.

Step 2: Create a .POT file
The next step is to create a .POT file. This file is the catalog of all the places in the theme files, that we want the text to be translated.
something like

#: archive.php:36 search.php:19
msgid "Read Full Post &#187;"
msgstr ""

which specifies the line number 36 in the archive.php file and the line number 19 in the search.php has the text “Read Full Post &#187;” which needs to be translated.
Similarly it has entries for each of the text items that has to be translated.

Step 3 : Translating the theme
This .POT file we created in the previous step, is the starting point for our translation effort.
Now somebody has to say if it is “Permanent Link” in english, it is called “Lien Permanent” in french or “Eslabón Permanente” in Spanish [I just used an online translator for arriving at this text].
So if somebody wants to translate the theme to Spanish, they will simply load the .POT file that we have for the theme into a software like PO Edit and enter the equivalent Spanish strings for each of the English string we have provided.
From this tool, we can generate a .MO file for Spanish translation or a .MO file for French etc.
Once a .MO file is created, it should be placed within the theme folder.

How does WordPress know to apply this .MO file?
Ok. We have a .MO file which contains the translated text for German, for example.
but for the WordPress to load this file, you need to change the wp-config.php file.
Look for

define ('WPLANG', '');

and change it to

define ('WPLANG', 'de');

This is for when you have a German Translated file. If your language is different, you should use your language code instead of ‘de’.

Thats it.
If a language file is found, then it will be used or otherwise it will use the text in English.

[This article is a draft of what I have understood so far, about making the theme ready for translation. As I learn more, I will update this post.

15 Comments

  1. wprocks

    Matthias

    April 1, 2008 at 8:31 am

    Wow, up until now I translated all your themes which I bought the “cumbersome” way… (of course I never released them)
    Good to know there’s an easier solution. If you make your themes “translation-ready” I will gladly help to translate them to German. 😉

  2. wprocks

    Milan Dinić

    April 4, 2008 at 8:31 am

    Hi Sadish! I am one of official translators of WordPress, maintaining Serbian translation. Also I’m using your theme MistyLook for my blog, but until now I translated it manually (like everybody) and didn’t updated regularly since it took much time for translation (currently I use version 3.3.1).
    I’ll as soon as possible translate MistyLook to Serbian and I’ll come back with some impressions.

    Maybe you already read this, but I’ll recommend you to read this article on Codex about translating WordPress, introduction of theme’s translation and also first and second great article from Urban Giraffe (note that this two articles are spited in several parts).

    Should we continue discussion here or on forum?

  3. wprocks

    Sadish

    April 4, 2008 at 8:32 am

    Thanks Milan for volunteering.

    I am going to update the theme page to provide downloads for each of the languages as and when people like you provide me with one.

    You will be given proper credit on the theme page.

    I would say we can continue talking about these things here, but if people wants to discuss any issues they face when using the theme, I suggest them to go to the forums.

    Thanks and I look forward to your contributions.

  4. wprocks

    Milan Dinić

    April 5, 2008 at 8:33 am

    There is some error in .pot file provided with theme. I couldn’t open it in poEdit, it gives me some errors. I opened it in text editor, but didn’t find reasons of this.
    Then I created new pot with poEdit from theme’s files and it works, but it will be better if you could create new (official) pot file and then test it in poEdit, if it can open then it should be fine, and then update theme’s release.

  5. wprocks

    Sadish

    April 5, 2008 at 8:33 am

    @Milan, Thank you for bringing this to my attention.
    Henrik corrected the mistylook.pot and gave it back to me. I have since updated the theme with the new mistylook.pot inside.

    Please download the mistylook theme now to get the correct version.

  6. wprocks

    Milan Dinić

    April 7, 2008 at 8:34 am

    This new pot file is valid and I translated it, but while testing, I saw some things:
    1) complete comments.php file is not translatable
    2) in functions.php line echo “”; _e(‘Learn More at’,’ml’); echo ” Matt’s Asides technique”;
    should be changed to echo “”; _e(‘Learn More at Matt’s Asides technique’,’ml’);
    Also, there are several places that should similar approach, like line echo “” . __(‘Hey’,’ml’) . ” ” . $displayName . “,”.__(‘thanks for your message! I’ll get back to you as soon as possible.’,’ml’).””;. For this, check out paragraph Notes on translation here.

    There is something that is not related to localization. In header.php lines 8 and 9 should be deleted, since there are special plugins which take care for this issue (like All in One SEO Pack). With current status, it makes even worse for SEO, since every page should have unique description tag and not all pages same one.

  7. wprocks

    Matthias

    April 8, 2008 at 8:34 am

    Yeah, but there are many people out there which haven’t even heard about SEO. For all those the title tags will look strange, if you remove the lines so I would keep them…
    Or Sadish could offer special SEO-themes in the future, together with a plugin. I think this could be a lucrative niche 😉
    (Just joking)
    But for example, this guy (http://www.wpseo.us) started to take 20 € if you want to use his seo plugin on “commercial” websites/blogs…

  8. wprocks

    Milan Dinić

    April 8, 2008 at 8:35 am

    I though about lines with description and keywords (see below), not title line, and I don’t see any value of this for any user (but I see negative value, since description is sometimes shown in SERPs, so it could affect lower CTR on links to your links, and this is not SEO, this is usability).


  9. wprocks

    Matthias

    April 8, 2008 at 8:35 am

    Sorry, I got mixed up with title tag, description and keywords… What you are saying is absolutely true!

  10. wprocks

    Sadish

    April 8, 2008 at 8:36 am

    Milan,

    People enter some descriptive text about their site, as their tag line. Most often this contains the right keywords associated with their site.

    I thought it will be best to display them as description and keywords for their site. That is why I added those lines in the header.php.

    I do not understand how this will affect the SEO in any negative way.
    Please take this as a new discussion in our forums, as this is going too much off-topic from this post.

  11. wprocks

    ravishankar

    April 21, 2008 at 8:36 am

    Sadish, I have seen many (including me) using mistylook theme as default and there are no tamil themes for self-hosted blogs. If it is ok for you, I can volunteer to translate starting with Mistylook and see whether we can easily replicate the work for your other themes.

    Thanks

  12. wprocks

    Sadish

    April 21, 2008 at 8:37 am

    I will be glad if you work on translating this theme to Tamil, my mother tongue. Let me know once you are done, I will put it online for all fellow tamilians.

  13. wprocks

    Tomoe Cooper

    October 24, 2009 at 8:37 am

    Dear Sadish
    I am such a big fan of your themes. Especially Misty Look as it is really romantic and lovely. I set up my blog awhile ago (http://tomoecooper.wordpress.com) and just learned how to have it hosted (http://www.LetLoveTouchYou.com).

    Q1: Do I have to copy and paste all the contents from my old blog to the new one or is there any other easier way? And…

    Q2: About internationalization… I am a novice here so I am not sure if it’s in line with what you’re discussing here but I want to have a site in Japanese along with my English site (and have a button to click on an English flag with English and Japanese flag for Japanese). Would you know anyone who can help me with this? Can you?

    Tomoe
    Tokyo, Japan

    • wprocks

      Milan Dinić

      November 1, 2009 at 8:38 am

      I’ll try to answer you.

      You need to follow instructions from Moving to WordPress.org
      You’ll need some plugin which enables multi language blog, like some from this or this lists.

      • wprocks

        Tomoe Cooper

        November 2, 2009 at 8:39 am

        Thank you so much Milan for your information. It was really helpful!

Leave a Reply

Your email address will not be published. Required fields are marked *

More in Uncategorized