WordPress is the most popular CMS in the World and used by hundreds of millions users. How is it possible while many users use different native languages? That is easy, WordPress it self is translated to many languages and provides powerfull translation mechanism for themes and plugins.
How to start?
1. Make sure that your theme and plugins are translation ready
All of our themes and plugins are translation ready :) But make sure that your theme have following function in your functions.php file:
load_theme_textdomain( 'PixelEmu', get_template_directory() . '/languages' );
Where PixelEmu is a unique identifier used in theme to translate strings and second parameters is location of language files.
What if theme or plugin is not translation ready?
You need to edit files and modify all strings.
<?php echo 'Some string'; ?>
<?php echo __('Some string', 'PixelEmu'); ?>
or shorten version:
<?php _e('Some string', 'PixelEmu'); ?>
Naw you are ready to translate the theme.
2. Translate WordPress Theme
By default, our themes are provided with English language and uses system called: gettext for translations, localization and internationalization. What does it mean?
Developer / Client can use gettext calls for every translatable variables used in theme. Basicaly, this means you can translate every word used in theme files.
All calls are collected in PO (Portable Object) and MO (Machine Object) or POT (Portable Object Template) files.
You can simply edit PO or POT files with any editor in order to translate strings.
But it is highly recommended to use a gettext editor like POEdit.
First open POEdit
Next open provided with theme PO/POT file localised in languages directory (eg. names: PixelEmu.po or en_GB.po)
Translate strings :)
Save file and make sure MO file will be generated (you can check this in POEdit Preferences).
Next you need to rename file. The name of the translation file is important and should reflect your language and country code. For example, English translation save as en_GB, French translation save as fr_FR.po, Polish save as pl_PL etc.
Language Codes: http://www.gnu.org/software/gettext/manual/html_chapter/gettext_16.html#Language-Codes
Country Codes: http://www.gnu.org/software/gettext/manual/html_chapter/gettext_16.html#Country-Codes
Move file to theme -> languages directory with your favourite FTP client.
3. Set your native language in WordPress
Go WordPress Admin Area -> Settings -> General -> Site Language
Choose your language and save settings.
4. Share your translation.
If you translate a theme or plugin, you can share your translation with community. Just contact with support and send PO/POT file to us. We will add these files during theme update and many people will be happy using your translation :)
Do you find this tutorial helpful? Please share! Thanks.