How to print localized taxonomy term in node template? ['taxonomy_term']->name; is printing term name, but not localized.
Use i18n_taxonomy_term_name() or entity_label().
thank you. if someone is looking for solution to print localized taxonomy terms, this is the code: terms are printed as strings, not links, sepatared by commas. (replace $node->field_yourfieldname with your name)
<?php $i = 0; $langcode = isset($options['language']) ? $options['language']->language : i18n_langcode(); foreach($node->field_yourfieldname['und'] as $term) { if($i == 0){ $term = $term['taxonomy_term']; $term = i18n_taxonomy_term_name($term, $langcode); print $term; } else { $term = $term['taxonomy_term']; $term = i18n_taxonomy_term_name($term, $langcode); print ', '. $term; } $i++; } ?>
Automatically closed -- issue fixed for 2 weeks with no activity.
Comments
Comment #1
webflo commentedUse i18n_taxonomy_term_name() or entity_label().
Comment #2
ali_b commentedthank you.
if someone is looking for solution to print localized taxonomy terms, this is the code:
terms are printed as strings, not links, sepatared by commas.
(replace $node->field_yourfieldname with your name)