You are here

function i18ntaxonomy_translation_tids in Internationalization 6

Returns an url for the translated taxonomy-page, if exists.

1 call to i18ntaxonomy_translation_tids()
i18ntaxonomy_translation_link_alter in i18ntaxonomy/i18ntaxonomy.module
Implementation of hook_alter_translation_link().

File

i18ntaxonomy/i18ntaxonomy.module, line 238
i18n taxonomy module

Code

function i18ntaxonomy_translation_tids($str_tids, $lang) {
  if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str_tids)) {
    $separator = '+';

    // The '+' character in a query string may be parsed as ' '.
    $tids = preg_split('/[+ ]/', $str_tids);
  }
  elseif (preg_match('/^([0-9]+,)*[0-9]+$/', $str_tids)) {
    $separator = ',';
    $tids = explode(',', $str_tids);
  }
  else {
    return;
  }
  $translated_tids = array();
  foreach ($tids as $tid) {
    if ($translated_tid = i18ntaxonomy_translation_term_tid($tid, $lang)) {
      $translated_tids[] = $translated_tid;
    }
  }
  return implode($separator, $translated_tids);
}