diff options
Diffstat (limited to 'modules/translation/translation.module')
-rw-r--r-- | modules/translation/translation.module | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/modules/translation/translation.module b/modules/translation/translation.module index e0ee18ff7..1fd12a5ee 100644 --- a/modules/translation/translation.module +++ b/modules/translation/translation.module @@ -502,8 +502,23 @@ function translation_path_get_translations($path) { */ function translation_language_switch_links_alter(array &$links, $type, $path) { $language_type = variable_get('translation_language_type', LANGUAGE_TYPE_INTERFACE); - if ($type == $language_type && 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); + + if ($type == $language_type && preg_match("!^node/(\d+)(/.+|)!", $path, $matches)) { + $node = node_load((int) $matches[1]); + + if (empty($node->tnid)) { + // If the node cannot be found nothing needs to be done. If it does not + // have translations it might be a language neutral node, in which case we + // must leave the language switch links unaltered. This is true also for + // nodes not having translation support enabled. + if (empty($node) || $node->language == LANGUAGE_NONE || !translation_supported_type($node->type)) { + return; + } + $translations = array($node->language => $node); + } + else { + $translations = translation_node_get_translations($node->tnid); + } foreach ($links as $langcode => $link) { if (isset($translations[$langcode]) && $translations[$langcode]->status) { |