If you wish to have a multilanguage site or blog based on the WordPress platform, qTranslate is the plugin for you. It makes really easy to develop and maintain multilanguage WordPress themes and sites. You have several way to provide texts in different languages. For example, you can take advantage of .po
and .mo
files by using the traditional __()
and _e()
functions in PHP:
<?php comments_number( __("No Comments","Text Domain"), __("One Comment","Text Domain"), __("% Comments","Text Domain") );?>
or you can embed directly multiple languages strings in code to avoid to change .mo files. You can do that by using long language tags
<?php _e("<!--:it-->Commenti<!--:--><!--:en-->Comments<!--:-->"); ?>
or quicktags
<?php _e("[:it]Commenti[:en]Comments"); ?>
The latest method is particolarly useful for titles and texts of widgets that you configure directly from the WordPress dashboard. It works also pretty well for the description of categories, but it fails for the Biographical Info when you edit a user. So I developed a simple snippet of code to solve the problem. Please, note that it takes advantage of an undocumented function of qTranslate, so I cannot guarantee that it will work in future releases too, but since it uses a very common function, I suspect it will. Here is:
<?php $desc_string = get_the_author_meta('description') ; $desc_array = qtrans_split($desc_string) ; $desc_lang = qtrans_getLanguage() ; echo $desc_array[$desc_lang] ; ?>
Lascia un commento