translation_node_view

Versions
7
translation_node_view($node, $build_mode)

Implements hook_node_view().

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

Code

modules/translation/translation.module, line 171

<?php
function translation_node_view($node, $build_mode) {
  if (isset($node->tnid) && $translations = translation_node_get_translations($node->tnid)) {
    $path = 'node/' . $node->nid;
    $links = language_negotiation_get_switch_links(LANGUAGE_TYPE_CONTENT, $path);
    if (is_object($links)) {
      $links = $links->links;
      // Do not show link to the same node.
      unset($links[$node->language]);
      $node->content['links']['translation'] = array(
        '#theme' => 'links',
        '#links' => $links,
        '#attributes' => array('class' => array('links', 'inline')),
      );
    }
  }
}
?>
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.