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. See original summary.

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);
  }
}
astonvictor’s picture

Status: Active » Closed (outdated)

D7 reached its EOL back in January 2025, and there is no active release for D7 for this module anymore.
Development or support is not planned for D7. All D7-related issues are marked as outdated in a bunch.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.