Localized taxonomy terms are not displayed in a View. Only the default language term is shown. I solved this issue writing a small module according to this article.

Perfect. But in one View i have two fields: term ID and Global PHP code. My question is: what needs to be changed in the Global PHP code below to have the localized terms displayed?

$term = taxonomy_term_load($data->tid);
//print l($term->name,"voices", array('query' => array('type' => $term->tid)));
print l($term->name,"voices", array('query' => array('f[0]' => 'field_production_type_:'.$term->tid), 'attributes' => array('class' => array($term->name))));

  $url = drupal_get_path_alias('taxonomy/term/'. $term->tid);
  $url_part = explode('/', $url);
  print l($term->name ,"voices/voiceovers/".$url_part[1], array('attributes' => array('class' => array($term->name))));

2 Answers 2


$term = taxonomy_term_load($tid); $translated_term = i18n_taxonomy_term_get_translation($term, $langcode);

  • Thanks a lot Namari, I replaced the first line of my code with yours: first line: $term = taxonomy_term_load($data->tid); into Your lines: $term = taxonomy_term_load($tid); $translated_term = i18n_taxonomy_term_get_translation($term, $langcode); But this didn't work out. I tried changing ($tid) into ($data->tid) then only the default language terms where displayed like before. Maybe i did something wrong. Would you mind to have another quick look at it and paste the complete piece of code?
    – Albert
    Commented Jun 12, 2015 at 8:41
  • try this: global $language; $lang_name = $language->language; //or use the one you want 'en', 'fr'... $term = taxonomy_term_load($data->tid); $translated_term = i18n_taxonomy_term_get_translation($term, $lang_name);
    – GwenM
    Commented Jun 12, 2015 at 9:04
  • if it doesn't have a look here drupal.stackexchange.com/questions/79037/…
    – GwenM
    Commented Jun 12, 2015 at 9:06

From the question details provided, I'm not sure if the i18nviews module is enabled (make sure it is).

Probably the best option might be to use i18n_taxonomy_term_get_translation as explained also in the questions:

Something else you may want to try to get the terms translated, is to use the setting (for Translation mode) Translate. Different terms will be allowed for each language and they can be translated (instead of 'Localize'). This setting can be found within admin/structure/taxonomy/<YourTaxonomy>/edit.

  • I do have i18nviews enabled. Without the custom module it only shows the term in the default language. I can imagine i need to change the code above with lines like: localized_term or localized_name but i don't know exactly which lines. Some suggestions for that would be very helpful.
    – Albert
    Commented Jun 11, 2015 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.