Translating your WordPress site using a POT file
This is a quick guide on how to translate your WordPress site using a POT file and tools involved in the process.
What framework is used for translating WP?
Using the gettext translation framework, there are three files involved in translating your wordpress site.
- POT (Portable Object Template) File
Using a program to search through your WordPress code for any text enclosed within a __e() or __() function will a POT file be generated. Within this file you will find the text available for translating. This file you will provide to your translator(s) to translate and return to you.
- PO (Portable Object) File
After you have received the translations you can then place them within the POT file and save your file as a PO file.
- MO File
The final step in the localization process is that the PO file is ran through a program that turns it into an optimized machine-readable binary file (MO file). Compiling the translations to machine code makes the localized program much faster in retrieving the translations while it is running.
Using poEdit to translate POT files
poEdit is an open source program for Windows, Mac OS X and UNIX/Linux which provides an easy-to-use GUI for editing PO and generating MO files.
Getting Started with poEdit
- Download and install poEdit
- Download the official WordPress POT file
- The poEdit screen
- Open the file in poEdit.(See Image) The box labeled(1) is the original message (in English) from the POT file. The box labeled (2) is where you add your translation. Boxes labeled (3) and (4) are used for adding comments about the messages. These come in handy if you are working with a team of translators and would like to pass around ideas through the PO file. Go to File → Save as… to save your translations in a PO file.When you are finished translating, go to File → Save as… again to generate the MO file.Or you can set your poEdit to always compile a MO file when saving changes by clicking File → Preferences and on the Editor tab check the Automatically compile .mo file on save box.
Configuring your site to use your translation files.
Now that you have your translation files prepared and ready for use you need to tell your site to use them.
Open and edit your wp-config.php file.
Set the global variable, WPLANG with the abbreviated name of the translation.
define ('WPLANG', 'language');
Where to place your translation files
Site wide translation (core wordpress code)
For text and phrases used within the core code of WordPress.
/wp-content/languages/language_COUNTRY.po
/wp-content/languates/language_COUNTRY.mo
Theme specific translation (theme specific)
For text and phrases used within themes and includes a domain within the __e() and __() functions.
Example: __e('Comment','theme_specific_domain') or __('Comment','theme_specific_domain')
/wp-content/themes/theme_directory/language_COUNTRY.po
/wp-content/themes/theme_directory/language_COUNTRY.mo
Translating Themes
Considering that themes have their own design and are custom there is a pretty good chance that there is some text that is unique to that theme and not included within the core code. For that reason, a separate or additional translation file is needed tailored to the theme (domain of the theme). Both translation functions, __e() and __() have a domain parameter which can be used to tell wordpress which translation files to use.
Configuring your theme to use its own translation files
Edit your functions.php file located within your active theme directory (/wp-content/themes/theme_directory/functions.php) and add the following before K2::init();
load_theme_textdomain('theme_domain');
K2::init();
If your domain is 'theme_domain' then your translation functions within your theme files will look similar to the following examples:
__e('Comment', 'theme_domain');
__('Comment','theme_domain');
It is good practice for theme developers to include a POT file with the theme files. In the event that you do not have a provided POT for your theme of choice you can use poEdit to scan the theme files and to generate a POT file. For instructions on how to configure poEdit to generate POT files visit http://scratch.wik.is/Translation/Translating_scratch.mit.edu/Creating_POT-Files.
After following the above steps you should now be able to reload your site with the new translations.
Sources:
- http://codex.wordpress.org/Translating_WordPress
- http://urbangiraffe.com/articles/translating-wordpress-themes-and-plugins/
- http://scratch.wik.is/Translation/Translating_scratch.mit.edu/Creating_P...





Comments
Does poedit work with the
Does poedit work with the latest version of wordpress? I seem to be having some issues but it may just be plug trouble. Maybe I just need to deactivate them and then try. canvas prints
recent comments widget
Hello,
Could you help me with the following:
On the English version of Wordpress I have translated myself everything I needed (into "my" Dutch). However, I don't find the file in which I can replace the "on" in the recent comments widget (e.g. "Mrs SoAndSo ON postX", in the recent comments menu (postX being clickable toward the actual post)).
I would like to replace "on" by "op". It sounds trivial, but I am a trickler for details.
Thanks a lot for helping me out!
Henri Pelissier
Belgium
Phil Walbridge - The website
Phil Walbridge
- The website shows the rankings and statistics of every state in which is good. Its is important that people will know the health information of every state so that they are aware about the rankings and statistics of their own state. I can use this as reference to my blog.
I'm currently trying to
I'm currently trying to design a wordpress site, where I integrate a blog, twitter, and customer service for my small business into the same front page.
photo on canvas
Thanks for the comment i
Thanks for the comment i agree with you.. ilan ver
Help
Thx for that guidance, i've a problem...
i'm translating PO file with poEdit the problem is when i save the changes in PO file @ some point translated PO file won't apply to the theme/plugin, i mean i've to remove theme/plugin (if any) and then reinstall plugin or theme to take effect.
WP version is 2.9.2 and target plugin is Wp-ecommerce theme is simpleCart
I'll appreciate if u help me on this.
quick help
I'm currently trying to design a wordpress site, where I integrate a blog, twitter, and customer service for my small business into the same front page. (a lot of huge conglomerates are doing similar stuff, like www.hccmis.com for example). Trying to get all of that translated together has been a chore in itself - as I'm trying to provide as well for the growing Latin American population in the states. A lot of the translator plugins that I tried either wouldn't work, or they have some other kind of issue that was holding me up. Thanks a lot for this back-end solution using POT files! I'm slowly becoming a developing expert, hah....
Thanks!
Thanks for the tutorial. I liked it a lot. It may be extremely helpful.
Thanks this is useful.
Thanks this is useful. Wordpress never ceases to amaze me with it's extensability and features.
Wall Art
Post new comment