[HOW TO] Get author info in more languages in WordPress



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] ;
?>

Please use Facebook only for brief comments.
For longer comments you should use the text area at the bottom of the page.

Facebook Comments

Leave a Reply




*


In compliance with the appropriate provisions of the law I state that this site is no profit, has not a predefined recurrence and is not updated according to a deadline. It may therefore not be considered an editorial product under Italian law #62 of March 7th, 2001. In addition, this site makes use of the right of citation for academic and criticism provided in Article 10 of the Berne Convention on copyright.