Hi

I'm using vocabulary with localized terms, i.e. terms and descriptions are commons to all languages and can be translated.

I want to build a block that shows all terms of that vocabulary, something like this:

<?php
$vid = 1; /* <---- put correct vocabulary ID here */
$terms = taxonomy_get_tree($vid);
print "<div class=\"item-list\"><ul>";
foreach ( $terms as $term ) {
print "<li>".
l($term->name,'taxonomy/term/'.$term->tid, array('title' => $term->name)).
"</li>";
} /* end foreach */
print "</ul></div>";
?>

The question is:
What function should I use to translate the terms?

Probably, the next line should include some i18n function to translate the name of the link:
l($term->name,'taxonomy/term/'.$term->tid, array('title' => $term->name)).

Thanks in advance.

Comments

jose reyero’s picture

Give a try and/or see the code in i18ntaxonomy (Multilingual Taxonomy) module

jose reyero’s picture

Status: Active » Fixed

It will depend on your vocabulary options.

For localizable ones, it should be:

tt("taxonomy:term:$term->tid:name", $term->name);
phKU’s picture

Thanks Jose, function tt() works fine for me :)

fjuan’s picture

Thank you very much

It works great whithin that code:

<?php
$vid = 9; /* <---- put correct vocabulary ID here */
$terms = taxonomy_get_tree($vid);
print "<div class=\"item-list\"><ul>";
foreach ( $terms as $term ) {
print "<li>".
l(tt("taxonomy:term:$term->tid:name", $term->name),'taxonomy/term/'.$term->tid, array('title' => $term->name)).
"</li>";
} /* end foreach */
print "</ul></div>";
?>
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.