translation_language_switch_links_alter

Versions
7
translation_language_switch_links_alter(array &$links, $type, $path)

Implement hook_language_switch_link_alter().

Replaces links with pointers to translated versions of the content.

Code

modules/translation/translation.module, line 406

<?php
function translation_language_switch_links_alter(array &$links, $type, $path) {
  if ($type == LANGUAGE_TYPE_CONTENT && $paths = translation_path_get_translations($path)) {
    foreach ($links as $langcode => $link) {
      if (isset($paths[$langcode])) {
        // Translation in a different node.
        $links[$langcode]['href'] = $paths[$langcode];
      }
      else {
        // No translation in this language, or no permission to view.
        unset($links[$langcode]);
      }
    }
  }
}
?>
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.