Worpress Theme translation

This is a bilingual web, but when you select up the spanish language, I want all (content+theme) to see in spanish. If your web is not polyglot, you can translate the theme clean and quicly in some following steps.

To keep a theme in spanish (or other language) i am based on anieto2k’s y yukei’s informaton in their blogs. anieto2k have a repository where you can share your translated theme.

We are going to detail the translate process. So that we are going to use this web based theme: Web 2.0 (download). But it can be used for any wordpress theme.

The Web 2.0 in spanish is here­ (for ISO-8859-1 charset, for UTF-8 charsets I leave the language files), and in theanieto2k’s repository.

Tagging strings

First will be to tag the strings that we want to translate inr our PHP code.

This is the most tedious action, PHP file by file tagging the strings as follows:

  • RETURN __(): For the strings in functions, returns trough the ‘return’ the translate string. traducida.
    • e.g.: <?php next_posts_link(‘Older Entries’) ?> ———–> <?php next_posts_link(__(‘Older Entries’,’w2′)) ?>
  • ECHO _e(): For the strings wrote directly in HTML, the function makes an ‘echo’ of the translate string.
    • e.g.: <h2>Not Found</h2> ———–> <h2><?php _e(‘Not Found’,’w2′); ?></h2>

‘w2’ is the translation theme domain. Used for the definition of various translation files in the same PHP code.

Then we will say to the PHP interpreter to translate where it find tags. We will do it in the header (…../wp-content/themes/web-20-100/header.php), loading the load_theme_textdomain(‘dominio’) function:

   <meta http-equiv="Content-Language" content="<?php the_language_locale(); ?>" />
   <?php load_theme_textdomain('w2'); ?>

WARNING: The language is defined in metacontent “Content-Language”, where we can take the value to conmut betewwen languages: es_ES.mo, es_AR.mo,… or not translate if it do not recognize.

Extracting tagged strings

The Gettext software will extract the strings tagged, it will unify them in a po extension file.

Istalling gettext on debian:

elite:~# apt-get install gettext
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias... Hecho
Paquetes sugeridos:
  cvs gettext-doc
Se instalarán los siguientes paquetes NUEVOS:
0 actualizados, 1 se instalarán, 0 para eliminar y 1 no actualizados.
Necesito descargar 2190kB de archivos.
Se utilizarán 6582kB de espacio de disco adicional después de desempaquetar.

In our theme root (…../wp-content/themes/web-20-100/ in my case) we will create a file (file-list.txt) which contains the name of all the files touched in the tagging point:


An axecute the gettext with the following options:

xgettext --keyword=__ --keyword=_e --language=PHP --files-from=file-list.txt --from-code=UTF-8 -d es_ES

We have the catalog generator file: es_ES.po. Let’s open it and you see all the strigs referenced for the function and line where they are allocated.

We can modify the theme, and we want remake the catalog, but with no loss of made translations. Then we can use -j option, this make a ‘join’ with the old version of es_ES.po. More or less:

xgettext --keyword=__ --keyword=_e --language=PHP --files-from=file-list.txt -j --from-code=UTF-8 -d es_ES

Translating strings

We will use PoEdit to translate text strings. For Debian (or debian based as Ubuntu) users we have PoEdit in the repositories:

elite:~# apt-get install poedit

Editing the file es_ES.po, and translating …:


When we save the file will generate the es_ES.mo file, this is the ‘machine code’ which really translates the strings.

WARNING: If in the .mo file (or .po after save) you see rare symbols (í), maybe you must change the PoEdit’s configuration charset, located in menu Catalog –> Options. And change, like me: ISO-8859-1.

Finally we must copy in the them root directory (…../wp-content/themes/web-20-100/ in my case) the es_ES.mo file.

2 thoughts on “Worpress Theme translation

  1. Hey Juan,

    nice to see another Web2.0*-fan 😉 Great to see somebody translate Web2.0* v1.50 but you might be happy to hear that I contacted Neil Merton (author of Web2.0*) to get the recently released v1.60 i18n ready!
    I’m almost finished and just sent Neil the second version with 1 or 2 fixes. When you translate it into spanish you can use poEdits library function which will search through all your *.mo files that you add to the library and will enter suggestions for the new file which you can accept or override. Saves a lot of typing 🙂


  2. Hi Christoph, thanks for your comment
    I saw the new version later, then I have made the translation for the 1.5 one.
    I will see if I can take some time to study this version and translate it.

Leave a Reply

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