Using WordPress plugins to automatically translate blog content

This is the easiest solution. A few WordPress plugins allows you to put some clickable flags in your sidebar, that will automatically translate your content to another language using, for example, Google Translate.
This is a great solution if you’re looking for a way to make your content available for people that doesn’t speak your language, but you guessed it, the automatic translation isn’t as good as a human translated text.

Anyways, if you’re interested in theses plugins, here’s a small list. I didn’t tried them all myself, though.

Using categories and a few hacks

If you’re a perfectionist, you probably don’t really like the automatic translations provided by Google. In my opinion, if it’s okay for a personal blog, but automatic translations should be avoided on a professional blog.

For this hack, we will use categories. Go to your dashboard and create categories/sub-categories following the example below:

English
    One category
    Two categories
Français
    Une catégorie
    Deux catégories
Deutsch
    Eine kategorie
    Zwei kategorien

Of course this is just an example, you can add as many categories as you want. The thing to remember here is that we’re using top level categories for languages, each of them having sub-categories organized by topics.

Now, you should post at least one example post in each sub-category. Once you’re done, we can start editing our header.php template.

The idea is quite simple: First, we must display the available languages, and then, a menu with the sub-category related to the current language. We must also think about defining a default language, which will be English in this example.

1 - Creating the language menu
Insert the following code where you want the language selection menu to appear:

<?php
wp_list_categories('title_li=');
$lang = 1; // Sets the default language
?>

As you can see, we just need the good old wp_list_categories() function to get our available languages.
Then, we have to keep a php variable containing the id of the top level category, in order to display the navigation menu in the selected language. We must give a default value to the $lang variable. This default value will be the category id of the language you want to set as default.

I noticed that many people should have trouble to find the ID of a particular category. If you do, you should definitely read this post.

2 - Navigation menu
Now, we got a php variable containing the id of the mother category. As the top-level categories are languages, we know which language the user is using.

We simply have to display second-level categories.

<ul>
<?php
wp_list_categories('title_li=&child_of=$lang');
?>
</ul>

3 - Retrieving category
Here’s a sample code you can use to automatically list posts from a category. This code get the current category (in this example, the language) and then displays the related posts.

<?php foreach((get_the_category()) as $category) {
      	$thecat = $category->cat_ID . ' ';
    	query_posts('child_of='.$thecat);
	if (have_posts()) : while (have_posts()) : the_post();
	   //Classic WP loop
	endwhile;endif;
?>

Want automatic updates? Subscribe to our RSS feed or
Get Email Updates sent directly to your inbox!
Digg This | Stumble it | Add to Del.icio.us | | Print This

There Are 9 Responses So Far. »

  1. 1 Danno
    Monday, October 6th, 2008 at 4:50 am

    I’m going to give this a try. Would love some fully bi-lingual people to weigh in and give their thoughts on the accuracy of machine translated text.

  2. 2 jbj
    Monday, October 6th, 2008 at 8:45 am

    My mother tongue is French, and to be honest, the machine translations are crap.
    I speak quite good English, so I prefer reading a good English text instead of a bad text in French.
    But in France many people don’t speak any other language than French…So the plugin can help that kind of people.

  3. 3 Anthony
    Monday, October 6th, 2008 at 9:17 am

    There are also other good plugins to translate blogs manually such as the one I developped : http://www.zen-dreams.com/en/zdmultilang/

  4. 4 Libin Pan
    Monday, October 6th, 2008 at 10:25 am

    Thanks for the great post!

    I have another pretty handy plugin, which can translate your comments( as well as posts) into any languages based on Google Ajax Translate.

    http://blog.libinpan.com/2008/08/04/google-ajax-translation-wordpress-plugin/

  5. 5 Albert
    Monday, October 6th, 2008 at 2:52 pm

    I’m using qtranslate in mi bilingual blog.

    http://www.qianqin.de/qtranslate/

    It’s easy to configure and to use.

  6. 6 jbj
    Tuesday, October 7th, 2008 at 12:46 am

    @All: Thanks for contributing by telling us which translation plugin you’re using!

  7. 7 Andrew. Virginia Lawer.
    Tuesday, October 7th, 2008 at 4:39 pm

    Awesome tutorial! I used to have automatic translations on my personal blog, but I removed it. Now I’m thinking that hiring a translator for my law firm blog could be a great idea. If only I was good enough to do it myself and actually speak another language. :)

  8. 8 Kayla Tahzan
    Friday, March 27th, 2009 at 9:56 pm

    Thanks! For your tutorials!

  9. 9 Morten
    Saturday, June 6th, 2009 at 5:12 am

    Does anybody know about plugin who will actually give you really multilanguage blog, where you have same contenct on different languages? would only way be to set up sub domains? like De.blogname.com, fr.blogname.com etc



Leave A Comment