Localization in WordPress Themes and Sites

December 28, 2006 – 9:25 am

Because WordPress is open source it is written by developers worldwide, not all of which speak or write code in English. More recently I have been looking to update the feel of CommerceCubes to something simple and put together.

Recently I downloaded a theme and started to customize it to my needs when I realized that the default language on the theme was German. I know that a few Germans have visited my site but still I want to keep everything in English because well that’s the language that I speak. Nothing against Germany though (Great People and Good Beer) :)

To curb this problem the concept of Localization was created to aid WordPress users globally. Localization is simply just what the name implies… it localizes your WordPress Blog or Theme to a specific region or language in this case. Most themes that require Localization usually have postings to files that you need to add to localize the site.

After some searching and a little learning I figured out the steps to localize a theme in WordPress. The first thing you are going to want to do is to edit the wp-config.php file that is located in the root directory of your site and that looks like this…

< ?php

// ** MySQL settings ** //

define(’DB_NAME’, ‘Your Database Name Here’); // The name of the database

define(’DB_USER’, ‘Your Username Here’); // Your MySQL username

define(’DB_PASSWORD’, ‘Your Password Here’); // …and password

define(’DB_HOST’, ‘Your Local Host Here’); // 99% chance you won’t need to change this value

// You can have multiple installations in one database if you give each a unique prefix

$table_prefix = ‘wp_’; // Only numbers, letters, and underscores please!

// Change this to localize WordPress. A corresponding MO file for the

// chosen language must be installed to wp-includes/languages.

// For example, install de.mo to wp-includes/languages and set WPLANG to ‘de’

// to enable German language support.

define (’WPLANG’, ‘en_US’);

define(’ABSPATH’, dirname(__FILE__).’/');

require_once(ABSPATH.’wp-settings.php’);

?>

In order to localize your site focus on this line of the above mentioned script…

define (’WPLANG’, ‘en_US’);

When you are downloading a localization script they end in the extension “.mo”. In my case the file name for localizing was called “en_US.mo”, so as you can see you set the WPLANG variable to “en_US” and drop the “.mo” entension. Lastly you’d save the wp-config.php file and upload this back to where your original wp-config.php resides on your server and overwrite the orignal file. But wait… there’s more…

Next you’ll want to create a “languages” directory under the “wp-includes” directory of your WordPress site. It looks like this…

http://www.yourwordpresssite.com/wp-includes/languages

From there you are going to upload your “.mo” file to the languages directory that you just created. After this is done the changes should take place automatically when you view your active theme and you should be good to go.

A very helpful article about this is located here off the WordPress site.

I am really enjoying WordPress because it is very well documented in an easy and clear manner that allows even the most novice person to use it unlike a lot of open source software currently available to people.

Luc

WordPress for Everyone

Post a Comment