You are here

function translation_url in Internationalization 5

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

Produces url of translated page

1 call to translation_url()
translation_get_links in translation/translation.module
Returns an array of links for all languages

File

translation/translation.module, line 1070

Code

function translation_url($url, $lang) {
  global $i18n_langpath;

  // If !url get from original request
  if (!$url) {
    $url = _i18n_get_original_path();
  }

  // If url has lang_prefix, remove it
  i18n_get_lang_prefix($url, true);

  // are we looking at a node?
  if (preg_match("/^(node\\/)([0-9]*)(.*)\$/", $url, $matches)) {
    if ($nid = translation_node_nid($matches[2], $lang)) {
      $url = "node/{$nid}" . $matches[3];
    }
  }
  elseif (preg_match("/^(taxonomy\\/term\\/)([^\\/]*)(.*)\$/", $url, $matches)) {

    //or at a taxonomy-listing?
    if ($str_tids = translation_taxonomy_tids($matches[2], $lang)) {
      $url = "taxonomy/term/{$str_tids}" . $matches[3];
    }
  }
  return $url;
}