You are here

function i18n_path in Internationalization 5.2

Same name and namespace in other branches
  1. 5.3 i18n.module \i18n_path()
  2. 5 i18n.module \i18n_path()

Produces i18n paths, with language prefix If path is empty or site frontpage, path = 'lang' Check for frontpage and search for alias before adding language

3 calls to i18n_path()
i18n_get_links in ./i18n.module
Function i18n_get_links
theme_translation_node_link in translation/translation.module
Theme a link to node translation
translation_get_links in translation/translation.module
Returns an array of links for all languages

File

./i18n.module, line 506
Internationalization (i18n) module

Code

function i18n_path($path, $lang) {
  if (!$path || $path == i18n_frontpage($lang)) {
    return $lang;
  }
  elseif ($alias = drupal_lookup_path('alias', $path)) {
    if ($prefix = i18n_get_lang_prefix($alias)) {

      // This alias will be valid only if it has the same language
      return $prefix == $lang ? $alias : $lang . '/' . $path;
    }
    else {

      // Alias without language prefix
      return $lang . '/' . $alias;
    }
  }
  else {

    // Alias for language path will be searched later
    return $lang . '/' . $path;
  }
}