[COME] Ottenere info su un autore in varie lingue in WordPress



Attenzione: questo articolo è disponibile in lingua italiana solo tramite traduzione automatica (Google Translate). Premete il pulsante qui sotto per attivare la traduzione. Tenete presente che una traduzione automatica è tutt'altro che perfetta.

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

Si prega di usare Facebook solo per commenti brevi.
Per commenti più lunghi è preferibile utilizzare l'area di testo in fondo alla pagina.

Commenti Facebook

Lascia una risposta





Nel rispetto delle apposite norme di legge si dichiara che questo sito non ha alcun scopo di lucro, non ha una periodicità prestabilita e non viene aggiornato secondo alcuna scadenza prefissata. Pertanto non può essere considerato un prodotto editoriale ai sensi della legge italiana n. 62 del 7 marzo 2001. Inoltre questo sito si avvale del diritto di citazione a scopo accademico e di critica previsto dall'Articolo 10 della Convenzione di Berna sul diritto d'autore.