You are here

function i18ntaxonomy_term_get_translations in Internationalization 6

Get term translations for multilingual terms. This works for multilingual vocabularies.

Parameters

$params: Array of query conditions. I.e. array('tid' => xxx)

$getall: Whether to get the original term too in the set or not.

Return value

An array of the from lang => Term.

2 calls to i18ntaxonomy_term_get_translations()
i18ntaxonomy_translate_terms in i18ntaxonomy/i18ntaxonomy.module
Translate an array of taxonomy terms.
i18ntaxonomy_translation_term_form in i18ntaxonomy/i18ntaxonomy.admin.inc
Produces a vocabulary translation form.

File

i18ntaxonomy/i18ntaxonomy.module, line 661
i18n taxonomy module

Code

function i18ntaxonomy_term_get_translations($params, $getall = TRUE) {
  foreach ($params as $field => $value) {
    $conds[] = "i.{$field} = '%s'";
    $values[] = $value;
  }
  if (!$getall) {

    // If not all, a parameter must be tid.
    $conds[] = "t.tid != %d";
    $values[] = $params['tid'];
  }
  $conds[] = "t.trid != 0";
  $sql = 'SELECT t.* FROM {term_data} t INNER JOIN {term_data} i ON t.trid = i.trid WHERE ' . implode(' AND ', $conds);
  $result = db_query($sql, $values);
  $items = array();
  while ($data = db_fetch_object($result)) {
    $items[$data->language] = $data;
  }
  return $items;
}