Implementation of hook_translation_link_alter().

Replaces links with pointers to translated versions of the content.

File

modules/translation/translation.module, line 337
Manages content translations.

Code

function translation_translation_link_alter(&$links, $path) {
  if ($paths = translation_path_get_translations($path)) {

    // Path can only start with "node/$nid" or "node/$nid/" here.
    $path = explode('/', $path);
    $node = node_load($path[1]);
    $translations = translation_node_get_translations($node->tnid);
    foreach ($links as $langcode => $link) {
      if (isset($paths[$langcode]) && $translations[$langcode]->status) {

        // Translation in a different node.
        $links[$langcode]['href'] = $paths[$langcode];
      }
      else {

        // No translation in this language, or no permission to view.
        unset($links[$langcode]);
      }
    }
  }
}