Menu

Translate a WordPress Theme in 3 Easy Steps

tradjrRecently, increasingly individuals are asking us learn how to translate a WordPress theme right into a language aside from English. And with an estimated 2 billion people now online, it’s no marvel. Fortuitously, it’s a reasonably easy course of, and I’ve boiled it down into three easy steps.

This tutorial assumes the WordPress theme to be translated has been localized utilizing the theGNU gettext framework. In different phrases, the theme is able to be translated. In case your theme has not been localized, you’ll must undergo every theme file and convert all English language textual content right into a gettext perform. See here for a brief description on how to do this.

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

POT stands for “Moveable Object Template,” and a POT file (aka .po file) is mainly an inventory of all of the English-language textual content discovered throughout the information of a localized WordPress theme. Yow will discover hyperlinks to the POT information for Solostream’s premium wordpress themes within the Solostream help discussion board here (you’ll simply must login to the discussion board first).

For those who’re utilizing a theme aside from a Solostream theme (gasp), examine with the theme writer to see if they provide a POT file. In the event that they don’t, you’ll be able to simply create your personal POT file with a free program known as POEdit (see Creating POT Files).

2. Translate the POT File and Add to Your Theme Folder

After getting the POT file, you’ll must open it in a program like POEdit, and translate the English language into your most popular language. When full, you’ll wish to save the file twice, as two separate information – a .po file and a .mo file. Once you save the information, you could identify them in keeping with your language code.

Discover a record of language codes at WordPress in your Language. For instance, the language code for English isen_EN, so you’d save the translated information as en_EN.po first, then en_EN.mo. When that’s accomplished, merely add the information to your theme folder.

three. Inform WordPress What Language to Use

In case your theme doesn’t already embody it, you’ll want so as to add the next line to the very high of your features.php file (simply earlier than the opening<?php tag):

<?php load_theme_textdomain('text_domain'); ?>

Discover “text_domain” above – it’s known as the textual content area identify. You need to use any identify you need, however you need to use the identical identify that’s used all through the theme within the gettext perform.

So, for instance, in case your gettext features look one thing like this:
<?php _e("Concerning the Writer", "wp-inspired"); ?>

You’ll wish to use “wp-inspired” rather than the text_domain above.

Lastly, should you haven’t accomplished so already, you’ll want to verify your wp-config.php file matches your language information. For instance, should you’re utilizing a French translation, you’ll want so as to add the fr_FR.po and fr_FR.mo information to your theme folder, then set your language in wp-config.php, like this:

outline ('WPLANG', 'fr_FR');

By the best way, your wp-config.php file is positioned in the principle listing the place all of your core WordPress information are positioned.

Save your wp-config.php file, add it to your WordPress set up, and you’re able to go.