DNExpert.com - domain name news & opinions!
Have domain industry news? Contact us!

Hello & welcome!

WordPress Localization – .po and .mo Files

I recently had to install a localized version of WordPress for a geo-specific domain name I was developing and I had to do some research on the topic as I wasn’t too familiar with WordPress localization implementation specifics – below are my research results.

By the way, localizing by definition is used by developers to mean turning on a different language or locale for a software installation.

WordPress uses the GNU gettext framework for it’s localization infrastructure – a message-level translation framework where every “message” shown to users is translated individually.

Localization messages for WordPress (like with most open-source software solutions) are defined in PO (Portable Object) files for different languages. The original language-independent message source file is stored as a POT – Portable Object Template – file. The PO files are converted into machine-readable binary files (MO file) to be used by the gettext framework.

WordPress is actually translated into some 60 odd languages already so the odds are your language translation MO file will actually be created already – it’s just a matter of downloading it from the WordPress in your language page.

With an existing translation localizing a WordPress installation is actually as easy as downloading a localized MO translation file, saving it in your wp-content/languages folder and changing one line of code in your wp-config.php – that line of code being: define (‘WPLANG’, ”).

For example, to localize WordPress into Czech, simply download the Czech mo file from http://cs.wordpress.org and put it in your wp-content/languages folder, set “define (‘WPLANG’, ‘cs_CZ’)” in your wp-config.php and you are off.

Since mo files are binary files, how do you modify translations within them?

The best tool to use to modify existing PO files (and save them as machine-readable MO files) or to create new PO files from POT files is the poedit open-source program. An excellent tool!

How do you localize WordPress for a language that is currently not supported?

This is defined in detail on the Translating WordPress page and is also quite easy to do.

Step 1: Download the original WordPress POT file.
Step 2: Open the POT file in poedit and Save As a localization PO file.
Step 3: In the opened poedit screen, translate the phrases English phrases into your language.
Step 4: Save the PO file – which will automatically create a MO file to be used with your WordPress installation.

2 comments

Leave a Reply