You are here

function i18n_taxonomy_taxonomy_term_presave in Internationalization 7

Implements hook_taxonomy_term_presave()

File

i18n_taxonomy/i18n_taxonomy.module, line 681
i18n taxonomy module

Code

function i18n_taxonomy_taxonomy_term_presave($term) {
  switch (i18n_taxonomy_vocabulary_mode($term->vid)) {
    case I18N_MODE_LANGUAGE:

      // Predefined language for all terms
      $term->language = taxonomy_vocabulary_load($term->vid)->language;
      break;
    case I18N_MODE_TRANSLATE:

      // Multilingual terms, translatable
      if (!isset($term->language)) {

        // The term may come from a node tags field, just if this is not a taxonomy form.
        // Or from any other object we are editing. So we use 'context' language here.
        $term->language = i18n_language_context()->language;
      }

      // Only for the case the term has no language, it may need to be removed from translation set
      if (empty($term->language)) {
        $term->i18n_tsid = 0;
      }
      break;
  }
}