Premium Themes

Do you know how many people use themes who do not post in English? Me neither, no idea, but I know that most themes are in English and only English. A premium theme needs to be different, it needs to think through the needs of the user and that means providing localisation. You will be amazed at how easy it us.

Before I begin here is a quick poll. I want to demonstrate, if I can, how many people there are out there who do not use English for either their blog or for the admin area of their WordPress installation:

So, how do you localise a theme? Well WordPress does all the hard work for you. As long as you decide to localise before you start then actually there is almost no work for you to do at all.

Choose a text domain

First you need to choose a text domain. This is a name that will let WordPress know which set of dictionary to use. It can be anything, as long as it is unique. I would suggest using the name of your theme. For this example I will use “Fun with WordPress”.

Tell WordPress where to find the dictionary

Next you need to tell WordPress the name of your dictionary using the load_theme_textdomain function. This should be placed at the top of your functions.php file so it loads everytime WordPress does.

load_theme_textdomain('Fun with WordPress');

You can include a second parameter in that function which is a path to the directory where the translations will be held. By default it will assume your themes directory.

Start theming

That is almost all the code you need to write. All you need to do now is to mark up your English text so that it gets translated. To do that you use two functions:

_('This is English text','Fun with WordPress');


_e('This is English text','Fun with WordPress');

They both tell WordPress to perform a translation (if desired and possible) on the text in the first parameter, using the dictionary in the second parameter. The difference between the two functions is that the first does the translation and returns the result, so it can be used in code, and the second echos the result, so it can be used for normal text. Here’s an example that provides the “read more” text for posts that use the more tag.


Using this, if someone using your theme uses the more tag to show only part of the content on the home page then they can choose a translation for the text that links to the rest of the post.

Create your .po file

A .po file is the file that will contain all your English words so people can translate them. You don’t need to go through the theme and find all the words there are tools that will do that for you. I Can Localize has a free tool that will even take a zip file to do your whole theme at once.

Promote your post

This is essential. Promote the fact that your theme is localised. There are many people out there who look for themes just to provide the translations. It doesn’t matter if you can’t translate it yourself as long as you have laid the groundwork.

But wait, is it really that easy?

I’ve painted this as being really easy because it is. But of course the devil is always in the details. Premium themes are about attention to detail and so is good localisation. Take the example I showed you above. What happens if you want the text to contain the post name. You can’t simple attach it to the end as you might do with English because other languages might not use the same text order. The sprintf function is a must:

sprintf( _( 'Read more of %s' , 'Fun with WordPress' ) , the_title('', '', false) );

Now the translation can specify where the title should go as well.

One of the best resources I have come across for dealing with all these issues, including word order, dates, javascript alerts, etc, is called Localizing WordPress Themes and Plugins at I Can Localize. Last time I produced a theme I used it extensively.

If you are producing a new theme I encourage you localise it. Not least because it is the right thing to do, but also (as I hope my poll shows) there are lot of people out there with an interest.