Index: globalredirect.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/globalredirect/globalredirect.module,v
retrieving revision 1.1.2.4.2.5.2.2
diff -u -p -r1.1.2.4.2.5.2.2 globalredirect.module
--- globalredirect.module	29 Dec 2007 16:33:42 -0000	1.1.2.4.2.5.2.2
+++ globalredirect.module	16 Apr 2008 19:22:10 -0000
@@ -18,24 +18,42 @@ function globalredirect_help($section) {
 function globalredirect_init() {
   if(isset($_REQUEST['q']) && function_exists('drupal_get_path_alias') && !isset($_REQUEST['destination'])) {
     
+    // Trim any trailing slash off the end (eg, 'node/1/' to 'node/1')
+    $request = trim($_REQUEST['q'], '/');
+
+    // Remove a language prefix in the path if existent (multilingual support).
+    if (!empty($request) && function_exists('i18n_get_lang')) {
+      $languages = language_list('enabled');
+      $languages = $languages[1];
+      $args = explode('/', $request);
+      $prefix = array_shift($args);
+      // Search prefix within enabled languages.
+      foreach ($languages as $language) {
+        if (!empty($language->prefix) && $language->prefix == $prefix) {
+          $request = implode('/', $args);
+          break;
+        }
+      }
+    }
+
+    // Early-out (the front page is requested).
+    if (empty($request)) {
+      return;
+    }
+
     // Get the Query String (minus the 'q'). If none set, set to NULL
     $query_string = drupal_query_string_encode($_GET, array('q'));
     if (empty($query_string)) {
       $query_string = NULL;
     }
 
-    // If current path is also the frontpage, redirect to http://www.example.com
-    if (!empty($_REQUEST['q']) && drupal_is_front_page()) {
+    // If current path is also the front page, redirect to the front page.
+    if (drupal_is_front_page()) {
       drupal_goto('', $query_string, NULL, 301);
     }
 
-    // Trim any trailing slash off the end (eg, 'node/1/' to 'node/1')
-    $request = trim($_REQUEST['q'], '/');
-    
-    // Check the path (eg, node/123) for a request
+    // Redirect to the URL alias of this path if existent.
     $alias = drupal_get_path_alias($request);
-    
-    // If alias is different to the request, redirect...
     if ($alias != $request) {
       drupal_goto($alias, $query_string, NULL, 301);
     }
@@ -45,7 +63,7 @@ function globalredirect_init() {
       drupal_goto($request, $query_string, NULL, 301);
     }
 
-    //If no alias was returned, the final check is to direct non-clean to clean - if clean is enabled
+    //If no alias was returned, the final check is to direct non-clean to clean - if clean is enabled.
     if ((bool)variable_get('clean_url', 0) && strpos(request_uri(), '?q=')) {
       drupal_goto($request, $query_string, NULL, 301);
     }
