You are here

function translation_taxonomy_save in Internationalization 5

Same name and namespace in other branches
  1. 5.3 translation/translation.module \translation_taxonomy_save()
  2. 5.2 translation/translation.module \translation_taxonomy_save()

Save taxonomy term translations

Parameters

$terms: Array of terms indexed by language

$trid: Optional translation set id

2 calls to translation_taxonomy_save()
translation_nodeapi_nat in translation/translation.module
NAT (Node As Term) integration for node translations
translation_taxonomy_term_form_submit in translation/translation.module
Form callback: Process vocabulary translation form

File

translation/translation.module, line 1009

Code

function translation_taxonomy_save($terms, $trid = 0) {

  // Delete old translations for this trid
  if ($trid) {
    db_query("UPDATE {term_data} SET trid = 0 WHERE trid= %d", $trid);
  }

  // Now pick up all the tids in an array
  $translations = array();
  foreach (i18n_supported_languages() as $lang => $name) {
    if (isset($terms[$lang]) && ($term = (array) $terms[$lang]) && ($tid = $term['tid'])) {
      $translations[$lang] = $tid;
    }
  }

  // Now set a translation set with all these terms.
  if (count($translations)) {
    $trid = is_numeric($trid) && $trid ? $trid : db_next_id('{term_data}_trid');
    db_query('UPDATE {term_data} SET trid = %d WHERE tid IN(%s)', $trid, implode(',', $translations));
  }
}