Index: translation.module =================================================================== --- translation.module (revision 5) +++ translation.module (working copy) @@ -322,7 +322,7 @@ function translation_path_get_translations($path) { $paths = array(); // Check for a node related path, and for its translations. - if ((preg_match("!^node/([0-9]+)(/.+|)$!", $path, $matches)) && ($node = node_load((int)$matches[1])) && !empty($node->tnid)) { + if ((preg_match("!^node/(\d+)(/.+|)$!", $path, $matches)) && ($node = node_load((int) $matches[1])) && !empty($node->tnid)) { foreach (translation_node_get_translations($node->tnid) as $language => $translation_node) { $paths[$language] = 'node/'. $translation_node->nid . $matches[2]; } @@ -336,16 +336,16 @@ * Replaces links with pointers to translated versions of the content. */ 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); + if (preg_match("!^node/(\d+)(/.+|)!", $path, $matches) && ($node = node_load((int) $matches[1]))) { + $translations = $node->tnid ? translation_node_get_translations($node->tnid) : array($node->language => $node); foreach ($links as $langcode => $link) { - if (isset($paths[$langcode]) && $translations[$langcode]->status) { + if (isset($translations[$langcode]) && $translations[$langcode]->status) { // Translation in a different node. - $links[$langcode]['href'] = $paths[$langcode]; + $links[$langcode]['href'] = 'node/'. $translations[$langcode]->nid . $matches[2]; } + elseif (!$node->language) { + $links[$langcode]['href'] = 'node/'. $node->nid; + } else { // No translation in this language, or no permission to view. unset($links[$langcode]);