By znat

2013-02-28 12:35:00 8 Comments

I have tried this

$term = taxonomy_term_load($tid);

and this:

$term = i18n_taxonomy_localize_terms(taxonomy_term_load($tid));

Both return the default language (English) term

I am using D7.


@kenorb 2013-10-02 10:27:38

1. Create translation sets (taxonomy example)

To translate a string, you should use two functions, depending on which i18n mode you use:

Localize mode: i18n_string_translation_update()

  $result_translation = i18n_string_translation_update(
    array('taxonomy', 'term', $tid, 'name'), // Path where to store source and translation.

Translate mode: i18n_translation_set_create()

  // 1. Load or create a translation set.
  $translation_set = ($source_term->i18n_tsid) ?
    i18n_translation_set_load($source_term->i18n_tsid) :
    i18n_translation_set_create('taxonomy_term', $vocabulary->machine_name);

      // 2. Add the full source term in this set.
  $translation_set->add_item($source_term, $source_term->language);

      // 3. Add the full translated term in this set.
  $translation_set->add_item($translated_term, $translated_term->language);

Strings for other contents and modules

When a module defines its own strings, it must use some additional functions to allow these string to be tracked and updated.

Define the textgroup by implementing hook_i18n_string_info(). This is how it looks (i18n_taxonomy module)

 * Implements hook_i18n_string_info()
function i18n_taxonomy_i18n_string_info() {
  $groups['taxonomy'] = array(
    'title' => t('Taxonomy'),
    'description' => t('Vocabulary titles and term names for localizable vocabularies.'),
    'format' => FALSE, // This group doesn't have strings with format
    'list' => FALSE, // This group cannot list all strings
    'refresh callback' => 'i18n_taxonomy_i18n_string_refresh',
  return $groups;

Read more at: Using the i18n API from other modules


How to associate programatically the translation of new term to the original existing term?

@Florian Limmer 2014-06-18 08:57:04

Here is how to rewrite the Finder menue display with localized tayonomy terms:

$query = new EntityFieldQuery;
$result = $query
->entityCondition('entity_type', 'taxonomy_term')
->propertyCondition('name', $display)
->propertyCondition('vid', 3) // Change this to Your ID!!

$found_tid = array_shift($result['taxonomy_term'])->tid;
// print $found_tid;

$tid = $found_tid;
$term = taxonomy_term_load($tid);
$translated_term = i18n_taxonomy_localize_terms($term);
print $translated_term->name;

@Draconid 2014-01-08 04:30:34

i18n_taxonomy_localize_terms works on getting site language

please check Home » Administration » Configuration » Regional and language » Languages to ensure the site language detection is working as you wanted

i got this done when site languages change on user language preference

@Bisonbleu 2013-02-28 13:55:02


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

Also, a good place to look for more information: /sites/all/modules/i18n/i18n_taxonomy/i18n_taxonomy.module

Related Questions

Sponsored Content

1 Answered Questions

How to show translated taxonomy terms in term listing in content listing style

1 Answered Questions

"Page not found" on translated page

1 Answered Questions

1 Answered Questions

1 Answered Questions

[SOLVED] How to get term ID from translated term name?

  • 2018-11-20 23:51:20
  • andileco
  • 53 View
  • 1 Score
  • 1 Answer
  • Tags:   views 8 i18n-l10n

1 Answered Questions

Taxonomy term not translated in edit node

1 Answered Questions

[SOLVED] Displaying translated taxonomy terms

3 Answered Questions

[SOLVED] How to get a term from the translated term name?

1 Answered Questions

[SOLVED] How to make language choice Required for Taxonomy term

Sponsored Content