Translate a WordPress Theme in three Effortless Steps

Translate a WordPress Theme in three Effortless Steps

Posted on Sep thirty 2010 by Alistair Barnett in Tutorials

Lately, more and more people are asking us how to translate a WordPress theme into a language other than English. And with an estimated two billion people now online, it’s no wonder. Fortunately, it’s a fairly straightforward process, and I’ve boiled it down into three plain steps.

This tutorial assumes the WordPress theme to be translated has been localized using the the GNU gettext framework. In other words, the theme is ready to be translated. If your theme has not been localized, you’ll need to go through each theme file and convert all English language text into a gettext function. See here for a brief description on how to do that.

1. Acquire or Create a POT File for Your WordPress Theme

POT stands for “Portable Object Template,” and a POT file (aka .po file) is basically a list of all the English-language text found within the files of a localized WordPress theme. You can find links to the POT files for Solostream’s premium wordpress themes in the Solostream support forum here (you’ll just need to login to the forum very first).

If you’re using a theme other than a Solostream theme (gasp), check with the theme author to see if they suggest a POT file. If they don’t, you can lightly create your own POT file with a free program called POEdit (see Creating POT Files).

Two. Translate the POT File and Upload to Your Theme Folder

Once you have the POT file, you’ll need to open it in a program like POEdit, and translate the English language into your preferred language. When accomplish, you’ll want to save the file twice, as two separate files – a .po file and a .mo file. When you save the files, you must name them according to your language code.

Find a list of language codes at WordPress in your Language. As an example, the language code for English is en_EN, so you would save the translated files as en_EN.po very first, then When that’s done, simply upload the files to your theme folder.

Trio. Tell WordPress What Language to Use

If your theme does not already include it, you’ll need to add the following line to the very top of your functions.php file (just before the opening <!–?php </code–> tag): <!–?php load_theme_textdomain(‘text_domain’); ?–>

Notice “text_domain” above – it’s called the text domain name. You can use any name you want, but you should use the same name that’s used via the theme in the gettext function.

So, for example, if your gettext functions look something like this:

You’ll want to use “wp-inspired” in place of the text_domain above.

Related movie:

Leave a Reply

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