Post Pic

Make your WordPress theme translatable

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!

14 Responses

Jun 29 2009 15:15

Where is Russian flag? :)

Jun 29 2009 17:42

Sorry for the flag :)

Jul 01 2009 16:42

There are some plugins that make automated translation, but the quality of translated content is really poor. Surely making, a own translated content is a hard work, but give a much higher quality to your blog.

Jul 02 2009 17:31

Maybe is not the best translation, but is impossible to translate it manually, so is very useful. Thanks

Jul 02 2009 19:01

I got the point that writer wanna express here. Its absolutely right that a blog should have a language that everyone can understand easily. Because most of the cases visitor see the blog and ignore if it’s in other language..

Jul 03 2009 18:24

Nice man.

Jul 06 2009 14:04

very usefull, many thanks

Jul 06 2009 23:27

Nice tip, and in combination with Google translate it can be very useful.

Jul 07 2009 13:43

@seo83,
Your comment are really nice..and i think any website could be a international languade. Keep it up!

Jul 07 2009 14:46

thanks for this recipes, so useful.

Oct 01 2009 17:24

@catswhocode : if you need help in Albanian language i can help you :)

Jan 07 2010 17:56

Worth to try. I always translate themes manually.

Feb 18 2010 17:54

Obviously that’s not enough. At the very least, theme designers should enclose messages to be displayed inside GETTEXT tags and provide a PO file of all the strings used. This should be a condition for a theme to be included in WP theme repository. I’m gonna start a campaign to that effect on the WP forums as I’ve had enough of themes hard coded in English, with no concern whatsoever for other languages! (am French by the way :-)

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required