Index: globalredirect.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/globalredirect/globalredirect.module,v
retrieving revision 1.1.2.4.2.5.2.3
diff -u -p -r1.1.2.4.2.5.2.3 globalredirect.module
--- globalredirect.module	4 Aug 2008 14:40:16 -0000	1.1.2.4.2.5.2.3
+++ globalredirect.module	6 Aug 2008 16:26:05 -0000
@@ -75,6 +75,32 @@ function globalredirect_init() {
     // Trim any trailing slash off the end (eg, 'node/1/' to 'node/1')
     $request = trim($_GET['q'], '/');
 
+    // If Content Translation module is enabled then check the path is correct
+    if (module_exists('translation') && (arg(0) == 'node') && is_numeric(arg(1)) && (arg(2) == '')) {
+      switch(variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE)) {
+        case LANGUAGE_NEGOTIATION_PATH_DEFAULT:
+        case LANGUAGE_NEGOTIATION_PATH:
+          // Check if there's a translation for the current language of the requested node...
+          $node_translations = translation_path_get_translations('node/'. arg(1));
+          // If there is, go to the translation.
+          if ($node_translations[$language->language] != '' && $node_translations[$language->language] != 'node/'. arg(1)) {
+            drupal_goto($node_translations[$language->language]);
+          }
+          // If there is no translation, change the language to fit the content!
+          else {
+            $node = node_load(arg(1));
+            if ($node->language != $language->language) {
+              $all_languages = language_list();
+              // Change the global $language's prefix, to make drupal_goto()
+              // follow the proper prefix
+              $language->prefix = $all_languages[$node->language]->prefix;
+              drupal_goto(drupal_get_path_alias('node/'. $node->nid));
+            }
+          }
+          break;
+      }
+    }
+
     // Check the path (eg, node/123) for the request
     $alias = drupal_get_path_alias($request);
 
