You are here

function translation_link in Internationalization 5

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

Implementation of hook_link().

File

translation/translation.module, line 815

Code

function translation_link($type, $node = NULL, $teaser = FALSE) {
  $languages = i18n_supported_languages();
  $links = array();
  if ($type == 'node' && variable_get('i18n_translation_node_links', 0) > ($teaser ? 1 : 0) && $node->translation) {
    foreach ($node->translation as $lang => $trnode) {

      // Add node link if published
      if ($trnode->status) {

        // If language is not enabled, we'll use current language for the prefix
        $baselang = variable_get('i18n_translation_links', 0) || !isset($languages[$lang]) ? i18n_get_lang() : $lang;
        $links['translation-' . $lang] = theme('translation_node_link', $trnode, $lang, $baselang);
      }
    }
  }
  return $links;
}