Make your WordPress theme translatable

June 29, 2009 at 9:50 am

When releasing a WordPress theme to the public, you have to keep in mind that many persons blogs using a different language than English. WordPress themes can be easily translated, especially using this recipe.

The first thing to do is to create a directory called languages in your theme directory.
Then, paste the following lines of code to your functions.php file:

// Make theme available for translation
// Translations can be filed in the /languages/ directory
load_theme_textdomain( 'your-theme', TEMPLATEPATH . '/languages' );
 
$locale = get_locale();
$locale_file = TEMPLATEPATH . "/languages/$locale.php";
if ( is_readable($locale_file) )
	require_once($locale_file);

At this point, you theme is ready for being translatable. Though, you guessed it, this is not the only thing to do for making your theme available in X different languages.
I’m not going to explain WordPress theme translating on here (Though a Cats Who Code tutorial should be written) so here are two extremly useful articles that you must read if you’re interested in the topic:

Thanks to ThemeShaper for the tip!