Translation of WordPress themes: _e function and .mo, .po files

This article is dedicated to the translation of WordPress themes without having to connect plugins like qTranslate X.

Quick algorithm is as follows:

1) PHP files have to use this type of function (for example h1 tag):

‘title’ – this is the text that we aim to translate. It will appear in the tag h1 of our theme.
‘softsprint’ – the name of the theme folder which has to be translated. In our case, the folder is named ‘softsprint’.
More about _e function can be read here:

2) Pulling the values for the translation from the PHP files using the online services like and then getting .po file

3) Open the created .po file in Poedit and define the translations for each value. There you have also to define the locale: for example, ru_RU:

4) Save our .po file and compile it into a .mo file. Compiled .mo file has to be renamed into (according to our language).
The list of languages and countries:

5) Put file to the languages, folder in our theme folder (in our case – softsprint). It is not necessary to place .po file in the folder, but save it for yourself – possibly you will need to edit / add new translations in the future;

6) Add the next code in the functions.php file (located in our theme folder):

‘softsprint’ – the name of our theme folder;
‘/languages’ – the folder where the file was placed.

More details about the function load_theme_textdomain are described here:
The result is a concise code in the PHP files without extra plugins (eg, qTranslate X) and constructions of such kind:

In addition, the translation editing is centralized (with a .po file) and does not need to open and edit every php file separately.

Cookies | Privacy Policy | Terms and ConditionsSoftSprint ©