Hello,

is it somehow possible to display the terms in the current users language if a term translation is available?

Comments

haggins created an issue.

korzh-nick’s picture

entity_translation & title solve this problem

1kubik’s picture

this can be done with the

theme_hierarchical_term_formatter()

theme function you find in the
hierarchical_term_formatter.module

function yourTheme_hierarchical_term_formatter($variables) {
  $items = array();
  $separator = filter_xss_admin($variables['separator']);
  $count = 0;
  foreach ($variables['terms'] as $item) {
    $count++;
    
    // the little translation lives here
      $term = i18n_taxonomy_localize_terms(taxonomy_term_load($item["tid"]));
    // than replace the $item['content'] with the translated $term->name

    if ($variables['item_wrapper']) {
      $items[] = sprintf('<%s class="taxonomy-term count-%s tid-%s">%s</%s>',
          $variables['item_wrapper'], $count, $item['tid'], $term->name, $variables['item_wrapper']);
    }
    else {
      $items[] = $term->name;
    }
  }
  if ($variables['wrapper']) {
    return sprintf('<%s class="terms-hierarchy">%s</%s>',
        $variables['wrapper'], join($separator, $items), $variables['wrapper']);
  }
  else {
    return join($separator, $items);
  }
}