You are here

function i18n_taxonomy_translation_term_tid in Internationalization 7

Get translated term's tid.

Parameters

$tid: Node nid to search for translation.

$language: Language to search for the translation, defaults to current language.

$default: Value that will be returned if no translation is found.

Return value

Translated term tid if exists, or $default.

2 calls to i18n_taxonomy_translation_term_tid()
i18n_taxonomy_allowed_values in i18n_taxonomy/i18n_taxonomy.module
Returns the set of valid terms for a taxonomy field.
i18n_taxonomy_translation_tids in i18n_taxonomy/i18n_taxonomy.module
Returns an url for the translated taxonomy-page, if exists.

File

i18n_taxonomy/i18n_taxonomy.module, line 542
i18n taxonomy module

Code

function i18n_taxonomy_translation_term_tid($tid, $language = NULL, $default = NULL) {
  $translation = db_query('SELECT t.tid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_data} a ON t.i18n_tsid = a.i18n_tsid AND t.tid <> a.tid WHERE a.tid = :tid AND t.language = :language AND t.i18n_tsid > 0', array(
    ':tid' => $tid,
    ':language' => $language ? $language : i18n_language_content()->language,
  ))
    ->fetchField();
  return $translation ? $translation : $default;
}