Web Development

A Guide for Creating Translatable WordPress Themes

English is the most illustrated language, used over the Internet, but still there are thousands of other languages available in the World. It is important to add all languages over the internet.

Over the past few years, the demand for transferable themes and plugins is increasing. Therefore, it is necessary to create transferable WordPress themes to facilitate the Worldwide WP users.


If you want to release a theme publicly, then you should consider the localization. Translations are usually carried about by making the use of special code in your WP theme. This file encompasses the actual translations and you can develop one for any language.

How to Translate WordPress?

Terms like Internationalization and localization are used to translate WordPress in any other languages for web users from assorted locales who use disparate dialects and different languages other than English.

Process of Making a Translatable WordPress Theme

Through this blog, you will learn how to transfer the WordPress theme for any language. You need to follow the following steps:

Add the needed functions

You can paste the following lines of coding on your [code]functions.php[/code] file.

[cc lang=”php”]
load_theme_textdomain( ‘your_text_domain’, TEMPLATEPATH.’/languages’ );

$locale = get_locale();
$locale_file = TEMPLATEPATH.”/languages/$locale.php”;
if ( is_readable($locale_file) ) {

In the first line, you can see the [code]load_theme_textdomain()[/code] function. It enables you to load a Text Domain. It gives you the liberty to choose any name but remember it should be unique and different.


Internationalize your WP theme

Use the php [code]gettext[/code] functions to translate WordPress theme. GetText has two functions: [code]_e[/code] and [code]__[/code]. The [code]_e[/code] function is used to print simple text, while [code]__[/code] function is used when the text to be showcased is already covered in PHP tags. Refer to below code block for example:

[cc lang=”php”]
_e(“The page you’re looking for doesn’t exist”, “your_text_domain”);

the_content(__(‘Read more…’, “your_text_domain”));

The worst part is that you need to replace each string by the required function. And this process can take a lot of time as it completely depends on how many strings have been used in the theme.

Creating .po file

You can easily translate your WP theme into any language, but to display text in a foreign language, you need to add a [code].po[/code] file. This file stands for Portable Object that incorporates a string, and its translation in another language.

The best part is that you need to find your theme files for all strings that need to be translated. With the help of icanlocalize.com, you can scan all PHP files and create [code].po[/code] files. Then, it will extract all strings enveloped in [code]__(“txt”, “domain”)[/code] and [code]_e(“txt”, “domain”)[/code] calls.


With the help of POEdit, you can edit the PO files. It is free software which is designed for this particular task.
You have to translate each text string and after this, you can save the .po file.


The last step is to define your WP locale. And, you can do it by getting your language and country code.

For example:

If your language is French and France is your residential Country, then your code will be [code]fr_FR[/code]. With the support of GNU get text manual that contains pages, will help you find both the Country and language code.

After getting language codes open your [code]wp-config.php[/code] file and hunt for the [code]WPLANG[/code] constant. If it is available then replace the current code by yours and if it doesn’t exists, then paste the following line with your code.

[cc lang=”php”]
define (‘WPLANG’, ‘fr_FR’);

That was quick and easy, do share your views for the same.


Leave a Reply

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