translation_link

Versions
6
translation_link($type, $node = NULL, $teaser = FALSE)

Implementation of hook_link().

Display translation links with native language names, if this node is part of a translation set.

Code

modules/translation/translation.module, line 158

<?php
function translation_link($type, $node = NULL, $teaser = FALSE) {
  $links = array();
  if ($type == 'node' && ($node->tnid) && $translations = translation_node_get_translations($node->tnid)) {
    // Do not show link to the same node.
    unset($translations[$node->language]);
    $languages = language_list();
    foreach ($languages as $langcode => $language) {
      if (isset($translations[$langcode])) {
        $links["node_translation_$langcode"] = array(
          'title' => $language->native,
          'href' => 'node/'. $translations[$langcode]->nid,
          'language' => $language,
          'attributes' => array('title' => $translations[$langcode]->title, 'class' => 'translation-link')
        );
      }
    }
  }
  return $links;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.