Cialis online Cialis online

Bilingual blog

A couple of years ago, Émilie asked me to set up our WordPress installation to allow publishing in both English and French. So here is how we achieved this. Technically, having a bilingual blog isn’t that complicated – it’s writing all the posts twice that takes some patience.

After trying out several things and plugins, we finally found what we needed: Polyglot. We still use the 0.4 that existed back then – and which still works nicely – but I’m sure the newer 2.5 version is even better (as a matter of fact, I really should update that eventually).

Polyglot is really simple to install and use. For installation, one must modify polyglot.php to define the languages to be used, then modify wp-config.php for the default language. Next, to allow visitors to view the site in the preferred language, the parameter &lp_lang_pref=en or &lp_lang_pref=fr must be added to the link for language choice. This parameter will create a cookie that will remember the preference of the visitor. As for the RSS links, they can be located by adding ?lp_lang_view=fr or ?lp_lang_view=en to the links.

For composing, it’s not complicated either: everything that is between <lang_en> </lang_en> tags will only appear if the language parameter is ‘en’. For example:
<lang_en>Here is a cool picture</lang_en><lang_fr>Voilà une belle image</lang_fr><img src=’coolpic.jpg’>

In this example, the text is translated according to the visitor’s language, and the image appears in both cases (no need to repeat it because it is not included in a language tag).

For more advanced users, it is also possible to create your bilingual theme by using a php Polyglot command directly in your theme files; for example this text that presents recent posts:
<?php lp(‘<lang_fr>Récents articles</lang_fr><lang_en>Recent posts</lang_en>’); ?>
In version 0.4, it was the lp command that was available, it think this has changed in the newer version to p__ or p__e.

When we started using Polyglot, bilingual blog plugins were pretty rare, and those that worked even more so. Polyglot has met our needs. There are probably more possibilities today, but I recommend it because it is simple and handles the job well.

There. Now all’s left is translating this post. ;)

One Response to “Bilingual blog”

  1. Karine

    Ben non, hen, François! Ça a pas l’air compliqué du tout! :P

Note: You can follow any responses to this entry by grabbing the comments' RSS.

Leave a Reply