Recently, 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, its no marvel. Fortuitously, its a reasonably easy course of, and Ive 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, youll 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 Solostreams premium wordpress themes within the Solostream help discussion board here (youll simply must login to the discussion board first).
For those whore 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 dont, 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, youll must open it in a program like POEdit, and translate the English language into your most popular language. When full, youll 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 thats 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, youll want so as to add the next line to the very high of your features.php file (simply earlier than the opening
<?php load_theme_textdomain('text_domain'); ?>
Discover text_domain above its known as the textual content area identify. You need to use any identify you need, however you need to use the identical identify thats 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"); ?>
Youll wish to use wp-inspired rather than the text_domain above.
Lastly, should you havent accomplished so already, youll want to verify your wp-config.php file matches your language information. For instance, should youre utilizing a French translation, youll 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.