Index: i18n.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/i18n/i18n.module,v
retrieving revision 1.41.2.43
diff -u -r1.41.2.43 i18n.module
--- i18n.module	8 May 2010 01:04:34 -0000	1.41.2.43
+++ i18n.module	25 May 2010 10:30:42 -0000
@@ -28,10 +28,24 @@
  * Special fix for site_frontpage, that may have been used before the language variables are loaded.
  */
 function i18n_init() {
-  global $language;
-
   // If not in bootstrap, variable init.
   if (!_i18n_is_bootstrap()) {
+    _i18n_init();
+    _i18n_init_mode();
+  }
+}
+
+/**
+ * Initialize multilingual variables and use them for site_frontpage
+ * 
+ * Special fix for site_frontpage, that may have been used before the language variables are loaded.
+ */
+function _i18n_init() {
+  static $done;
+  
+  // Prevent this function from running twice;
+  if (!isset($done)) {
+    $done = TRUE;
     $default_frontpage = variable_get('site_frontpage', 'node');
 
     i18n_variable_init();
@@ -44,6 +58,33 @@
 }
 
 /**
+ * Initialize selection mode
+ */
+function _i18n_init_mode() {
+  if (i18n_selection_mode() != 'off') {
+    // Node language when loading specific nodes or creating translations.
+    if (arg(0) == 'node' ) {
+      if (($node = menu_get_object('node')) && $node->language) {
+        i18n_selection_mode('node', $node->language);
+      }
+      elseif (arg(1) == 'add' && !empty($_GET['translation']) && !empty($_GET['language'])) {
+        i18n_selection_mode('translation', db_escape_string($_GET['language']));
+      }
+    }
+    elseif (arg(0) == 'admin') {
+      // There are some exceptions for admin pages.
+      if (arg(1) == 'content' && user_access('administer all languages')) {
+        // No restrictions for administration pages.
+        i18n_selection_mode('off');
+      }
+      elseif (arg(1) == 'build' && arg(2) == 'menu-customize') {
+        // All nodes available when editing custom menu items.
+        i18n_selection_mode('off');
+      }
+    }
+  }  
+}
+/**
  * Implementation of hook_help().
  */
 function i18n_help($path = 'admin/help#i18n', $arg) {
@@ -346,37 +387,13 @@
  *  custom = add custom where clause, like "%alias.language = 'en'".
  */
 function i18n_selection_mode($mode = NULL, $params = NULL) {
-  static $current_mode = NULL;
+  static $current_mode;
   static $current_value = '';
   static $store = array();
 
-  // Initialization, first time this runs with no explicit mode.
-  if (!$current_mode && !$mode) {
+  // Initialization, first time this runs
+  if (!isset($current_mode)) {
     $current_mode = variable_get('i18n_selection_mode', 'simple');
-    if ($current_mode != 'off') {
-      // Node language when loading specific nodes or creating translations.
-      if (arg(0) == 'node' ) {
-        if (($node = menu_get_object('node')) && $node->language) {
-          $current_mode = 'node';
-          $current_value = $node->language;
-        }
-        elseif (arg(1) == 'add' && !empty($_GET['translation']) && !empty($_GET['language'])) {
-          $current_mode = 'translation';
-          $current_value = db_escape_string($_GET['language']);
-        }
-      }
-      elseif (arg(0) == 'admin') {
-        // There are some exceptions for admin pages.
-        if (arg(1) == 'content' && user_access('administer all languages')) {
-          // No restrictions for administration pages.
-          $current_mode = 'off';
-        }
-        elseif (arg(1) == 'build' && arg(2) == 'menu-customize') {
-          // All nodes available when editing custom menu items.
-          $current_mode = 'off';
-        }
-      }
-    }
   }
 
   if (!$mode) {
