summaryrefslogtreecommitdiff
path: root/modules/translation
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-10-25 15:14:33 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-10-25 15:14:33 +0000
commit08f59215f7ddefc29daf5a47c113bb8566ff06cb (patch)
tree507e10c6cc7724f7b88de5a1d2b09c3a426d6704 /modules/translation
parent14d19b22cac31ac457d2cba01130d4bd4c80588e (diff)
downloadbrdo-08f59215f7ddefc29daf5a47c113bb8566ff06cb.tar.gz
brdo-08f59215f7ddefc29daf5a47c113bb8566ff06cb.tar.bz2
#518364 by plach, neochief, Ryan Palmer: Fixed Nodes with one language don't affect the language switcher block.
Diffstat (limited to 'modules/translation')
-rw-r--r--modules/translation/translation.module16
1 files changed, 8 insertions, 8 deletions
diff --git a/modules/translation/translation.module b/modules/translation/translation.module
index 837e1abde..2dc318b70 100644
--- a/modules/translation/translation.module
+++ b/modules/translation/translation.module
@@ -484,7 +484,7 @@ function translation_supported_type($type) {
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];
}
@@ -499,18 +499,18 @@ 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 && $paths = translation_path_get_translations($path)) {
- $path = explode('/', $path);
- $node = node_load($path[1]);
- $translations = translation_node_get_translations($node->tnid);
+ 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);
+
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];
}
else {
// No translation in this language, or no permission to view.
- unset($links[$langcode]);
+ unset($links[$langcode]['href']);
+ $links[$langcode]['attributes']['class'] = 'locale-untranslated';
}
}
}