simple solution create new .po and .mo file put in your theme folder thats it
WordPress uses a standard localization framework called GNU gettext. This framework provides the programmer the ability to mark text inside code as being suitable for localization. The role of the translator is to take these marked pieces of text and produce a language-specific localization. No code needs to change and you do not need to understand how the program works.
Text is marked by wrapping it with special PHP functions. It is not important to know how these functions work, but it will be helpful to recognize them:
__($text)– Looks for a translated version of
$textand returns the result
_e($text)– Looks for a translated version of
$textand echo the result to the screen (i.e. effectively it is
$numberis 1 then looks for a translated version of
$single. If number is more than 1 then looks for a translated version of
(Source: Urban Giraffe)
Putting this into context, it means that all our text in our template files (.php files) have been wrapped in gettext functions. This enables us to create a Portable Object File (or .po file) which contains all the text for the theme. This has already been done by us at WooThemes.
The user (that’s you) then has the ability to use a program (we’ll get back to this later) to translate this .po file into another language, add it to the theme directory, and have a translated theme!
Before we start
Before you can start to translate the theme, you need to make sure that the theme has been made ready for translation. All our new themes will support localization and include a language file (.po file) which contains all the English texts, and soon all our old themes will be upgraded as well.
If you are not certain if your theme has been made ready for translation/localization, you can simply check if there is a “/lang/themename.po” file in your theme folder. If there isn’t one, you will need to download the latest version of the theme and check if the .po file existst there. If it does include a translation file, you will need to upgrade your theme to be able to translate it.
How to translate
To translate your theme, you will need to use Poedit to translate the included Portable Object file (.po file), which will then create a Machine Object file (.mo file) which we will upload to our theme folder for WordPress to read.
Follow these steps to translate your .po file into another language and make a .mo file:
- Download and install Poedit, the program we will use to translate our .po file.
- Open the themename.po file found in your /lang/ folder with poedit.
- Now go through and translate all the text one line at a time in the bottom box.
- Save the file after you’re done. This will output a .po and .mo file.
Translating the .po file with Poedit
Before we can upload our new .mo file, we need to make sure we named it correctly, as it has to match your desired language locale. See the complete list of language codes and country codes to find your exact locale.
We’ll use Norwegian as the example here, so first we find the language code (nb – Norsk Bokmål) and the country code (NO). We than rename our .mo file to nb_NO.mo and upload to the root of our theme folder e.g.
The last step is to make sure your WordPress config file, wp-config.php, is setup with your locale, which in this case is Norwegian. So open wp-config.php and check that what you have in your define() function. For Norwegian it will look like this:
define ('WPLANG', 'nb_NO');
Once you have matched the wp-config.php setting to our .mo filename, you should have successfully translated your WooTheme into another language.
Share your language
We want to make it easier for users to get the theme in their language, so if you have translated your theme into your language, we hope you can share the .mo file with us, so new users don’t have to translate the theme themselves.
Please send us your translated files (.po and .mo) files to firstname.lastname@example.org and we will put your file up in our repository.