--- i18n.module	2007-10-30 19:12:35.000000000 +0200
+++ i18n.module.php	2008-02-15 12:11:17.000000000 +0200
@@ -16,7 +16,7 @@ define('LANGUAGE_SUPPORT_EXTENDED', 2);
 
 /**
  * Module initialization
- * 
+ *
  * Get language from path if exists and Initialize i18n system
  */
 
@@ -43,28 +43,30 @@ function _i18n_init(){
   global $i18n_langpath;
   $path = _i18n_get_original_path();
   $i18n_langpath = i18n_get_lang_prefix($path);
-}  
+}
 
 /**
  * Language block
- * 
+ *
  * This is a simple language switcher which knows nothing about translations
  */
-function i18n_block($op = 'list', $delta = 0) {
+function i18n_block($op = 'list', $delta = 0, $edit = array()) {
   if ($op == 'list') {
     $blocks[0]['info'] = t('Language switcher');
   }
   elseif($op == 'view') {
-    $blocks['subject'] = t('Languages');
     $query = drupal_query_string_encode($_GET, array('q'));
-    $blocks['content'] = theme('item_list', i18n_get_links($_GET['q'], empty($query) ? NULL : $query));
+    $query = empty($query) ? NULL : $query;
+    $links = i18n_get_links($_GET['q'], $query);
+    $blocks['subject'] = t('Languages');
+    $blocks['content'] = theme('item_list', $links);
   }
   return $blocks;
 }
 
 /**
  * Implementation of hook_init()
- * 
+ *
  * May do a redirect from home page for not to get wrong versions in cache
  * Warning: when in bootstrap mode, this may be called before i18n_get_lang()
  */
@@ -86,7 +88,7 @@ function i18n_init(){
       _i18n_goto($lang);
     } else {
       $_GET['q'] = i18n_frontpage($lang);
-    } 
+    }
   } elseif ($lang == $path) { // When path is only language code
     $_GET['q'] = i18n_frontpage($lang);
   }
@@ -97,8 +99,8 @@ function i18n_init(){
   // If not in bootstrap, variable init
   if(!_i18n_is_bootstrap()){
     //include drupal_get_path('module', 'i18n').'/i18n.inc';
-    i18n_variable_init();    
-  }  
+    i18n_variable_init();
+  }
 }
 
 /**
@@ -115,7 +117,7 @@ function i18n_help($section = 'admin/hel
       $output .= '<li>'.t('Keeps the language setting accross consecutive requests using URL rewriting').'</li>';
       $output .= '<li>'.t('Provides a block for language selection and two theme functions: <i>i18n_flags</i> and <i>i18n_links</i>').'</li>';
       $output .= '<li>'.t('Support for long locale names').'</li>';
-      $output .= '<li>'.t('Multilingual menu items').'</li>';      
+      $output .= '<li>'.t('Multilingual menu items').'</li>';
       $output .= '</ul>';
       $output .= '<p>'. t('For more information please read the <a href="@i18n">on-line help pages</a>.', array('@i18n' =>'http://drupal.org/node/31631')) .'</p>';
       return $output;
@@ -149,8 +151,8 @@ function i18n_menu($may_cache) {
       'title' => t('Manage languages'),
       'description' => t('Configure languages.'),
       'callback' => 'locale_admin_manage',
-      'type' => MENU_LOCAL_TASK);  
-  } else {   
+      'type' => MENU_LOCAL_TASK);
+  } else {
     if (arg(0) == 'node') {
       if(isset($_POST['language']) && $_POST['language']) {
         $language = $_POST['language'];
@@ -189,13 +191,13 @@ function i18n_nodeapi(&$node, $op, $teas
           $item['path'] = ($item['path']) ? $item['path'] : "node/$node->nid";
           $item['type'] = $item['type'] | MENU_MODIFIED_BY_ADMIN;
           if ($item['mid']) {
-            // Update menu item 
+            // Update menu item
             db_query("UPDATE {menu} SET pid = %d, path = '%s', title = '%s', description = '%s', weight = %d, type = %d, language = '%s' WHERE mid = %d", $item['pid'], $item['path'], $item['title'], $item['description'], $item['weight'], $item['type'], $node->language, $item['mid']);
             drupal_set_message(t('The menu item %title has been updated with node language.', array('%title' => $item['title'])));
           } elseif(SAVED_NEW == menu_save_item($item)) {
             // Creating new menu item with node language
             db_query("UPDATE {menu} SET language = '%s' WHERE mid = %d", $node->language, $item['mid']);
-            drupal_set_message(t('The menu item %title has been added with node language.',  array('%title' => $item['title'])));         
+            drupal_set_message(t('The menu item %title has been added with node language.',  array('%title' => $item['title'])));
           }
           menu_rebuild();
           unset($node->menu); // Avoid further processing by menu module
@@ -209,7 +211,7 @@ function i18n_nodeapi(&$node, $op, $teas
           }
         }
         break;
-      case 'delete': 
+      case 'delete':
         db_query('DELETE FROM {i18n_node} WHERE nid=%d', $node->nid);
         break;
       case 'prepare':
@@ -217,16 +219,16 @@ function i18n_nodeapi(&$node, $op, $teas
         if (arg(3) == 'parent' && is_numeric(arg(4)) && ($parent = node_load(arg(4))) && $parent->language) {
           $node->language = $parent->language;
           i18n_selection_mode('node', $parent->language);
-        } 
+        }
         break;
       }
-  }   
+  }
 }
 
 
 /**
  * Implementation of hook_taxonomy
- * 
+ *
  * $edit parameter may be an array or an object !!
  */
 function i18n_taxonomy($op, $type, $edit = NULL) {
@@ -235,12 +237,12 @@ function i18n_taxonomy($op, $type, $edit
     case 'term/insert':
     case 'term/update':
         $language = isset($edit['language']) ? $edit['language'] : '';
-      db_query("UPDATE {term_data} SET language='%s' WHERE tid=%d", $language, $edit['tid']);    
+      db_query("UPDATE {term_data} SET language='%s' WHERE tid=%d", $language, $edit['tid']);
       break;
-    case 'vocabulary/insert':    
+    case 'vocabulary/insert':
     case 'vocabulary/update':
         $language = isset($edit['language']) ? $edit['language'] : '';
-        db_query("UPDATE {vocabulary} SET language='%s' WHERE vid=%d", $language, $edit['vid']);    
+        db_query("UPDATE {vocabulary} SET language='%s' WHERE vid=%d", $language, $edit['vid']);
         if ($language && $op == 'update') {
           db_query("UPDATE {term_data} SET language='%s' WHERE vid=%d", $edit['language'], $edit['vid']);
           drupal_set_message(t('Reset language for all terms.'));
@@ -251,7 +253,7 @@ function i18n_taxonomy($op, $type, $edit
 
 /**
  * Implementation of hook_user()
- * 
+ *
  * Switch to user's language after login
  */
 function i18n_user($op, &$edit, &$account, $category = NULL) {
@@ -263,10 +265,13 @@ function i18n_user($op, &$edit, &$accoun
 
 /**
  * Form builder function.
- * 
+ *
  * Some options have been removed from previous versions:
  * - Languages are now taken from locale module unless defined in settings file
  * - Language dependent tables are authomatically used if defined in settings file
+ *
+ * @return array
+ *  Drupal Form
  */
 function i18n_admin_settings() {
   // Check languages
@@ -281,7 +286,21 @@ function i18n_admin_settings() {
     '#options' => array(t('Disabled'), t('Enabled' )),
     '#description' => t("User browser language for home page and links without language prefix."),
   );
-  
+  // Language prefix
+  $form['prefix'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Language prefix'),
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+    '#description' => t('Note: If you wish comparability with navigation mode (without language prefix), when module i18n is disabled, disable settings.'),
+  );
+  $form['prefix']['i18n_prefix_default'] = array(
+    '#type' => 'radios',
+    '#title' => t('Language prefix for default language'),
+    '#default_value' => variable_get('i18n_prefix_default', 0),
+    '#options' => array(t('Disabled'), t('Enabled' )),
+    '#description' => t("Add a language prefix to Drupal paths when the current language is the default language. Some established sites or single language sites with default language is not English may wish to disable language prefix of Drupal paths when enabling i18n module."),
+  );
   // Language icons
   $form['icons'] = array(
     '#type' => 'fieldset',
@@ -320,7 +339,7 @@ function i18n_admin_settings() {
     '#options' => _i18n_selection_mode(),
     '#description' => t('Determines which content to show depending on language.'),
   );
-    
+
   return system_settings_form($form);
 }
 
@@ -330,7 +349,7 @@ function i18n_admin_settings() {
 
 /**
  * Get localized language list, sort alphabetically
- * 
+ *
  * @param $all
  *   TRUE for all languages, not only enabled
  */
@@ -355,15 +374,18 @@ function i18n_supported_languages($all =
 }
 
 /**
- * Returns default language
+ * Returns default language.
+ *
+ * @return string
+ *  Default language code.
  */
 function i18n_default_language(){
-  return i18n_languages('site_default'); 
+  return i18n_languages('site_default');
 }
 
 /**
  * Check whether language is RTL
- * 
+ *
  * @param $language
  *   Language to check, defaults to current language
  */
@@ -374,7 +396,7 @@ function i18n_language_rtl($language = N
 
 /**
  * Get language properties
- * 
+ *
  * @param $code
  *   Language code
  * @param $property
@@ -387,7 +409,7 @@ function i18n_language_property($code, $
 
 /**
  * Get locale languages plus i18n language settings
- * 
+ *
  * @param $key
  *   Data to be returned, defaults to 'active'
  *   'active' => array of enabled languages with native name
@@ -427,48 +449,76 @@ function i18n_languages($key = 'active')
 
 /**
  * Get language from browser settings, but only if it is a valid language
+ *
+ * @return string
+ *  Language code.
  */
 function i18n_get_browser_lang() {
-  $languages = i18n_supported_languages();
-  $exploded_server = explode(";", $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
-  $accept=explode(',', array_shift($exploded_server));
-  foreach ($accept as $lang) {
-    if(empty($lang)) {
-      continue;
-    } elseif (array_key_exists($lang, $languages)) {
-      return $lang;
-    } elseif (array_key_exists(substr($lang, 0, 2), $languages)) {
-      return substr($lang, 0, 2);
+  static $browser_lang;
+  if (!isset($browser_lang)) {
+  	$languages = i18n_supported_languages();
+    $exploded_server = explode(";", $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
+    $accept = explode(',', array_shift($exploded_server));
+    $browser_lang = '';
+    foreach ($accept as $lang) {
+      if (($lang = @trim($lang)) &&
+            (array_key_exists(($lang = strtolower($lang)), $languages)
+              || array_key_exists(($lang = substr($lang, 0, 2)), $languages))) {
+        $browser_lang = $lang;
+        break;
+      }
     }
   }
+  return $browser_lang;
 }
 
 /**
  * Get language code from path.
  *
  * @param $path
+ *  Drupal path.
  * @param $trim
- *   TRUE to remove language code from $path
+ *  TRUE to remove language code from $path.
+ *
+ * @return string
+ *  Language code.
  */
 function i18n_get_lang_prefix(&$path, $trim = FALSE) {
   $exploded_path = explode('/', $path);
-  $maybelang = array_shift($exploded_path);
+  $maybelang = @strtolower(array_shift($exploded_path));
   $languages = i18n_languages();
-  if (array_key_exists($maybelang, $languages)){
-    if ($trim) {
-      $path = trim(substr($path, strlen($maybelang)),'/');
-    }
-    return $maybelang;
+  if (!array_key_exists($maybelang, $languages)){
+    $maybelang = ''; // NO Language code.
+  } elseif ($trim) {
+    $path = substr($path, strlen($maybelang) + 1);
   }
+  return $maybelang;
 }
 
 /**
  * Language dependent front page
- * This function will search for aliases like 'en/home', 'es/home'...
+ * This function will search for aliases like 'en/home', 'es/home'...,
+ * but for default language return aliase without prefix
+ *
+ * @param string [optional] $lang
+ *  ISO 639 language code.
+ *
+ * @return string
+ *  Language dependent path of front page.
  */
 function i18n_frontpage($lang = NULL) {
-  $lang = $lang ? $lang : _i18n_get_lang();
-  return i18n_get_normal_path($lang.'/'.variable_get('site_frontpage','node'));
+  static $paths = array();
+  $lang = $lang ? strtolower(@trim($lang)) : _i18n_get_lang();
+  if (!isset($paths[$lang])) {
+    // Case when add language prefix for default_language
+    $bool = (!variable_get('i18n_prefix_default', 0)
+          && $lang == i18n_default_language());
+    $path = $bool
+          ? variable_get('site_frontpage','node')
+          : $lang.'/'.variable_get('site_frontpage','node');
+    $paths[$lang] = i18n_get_normal_path($path);
+  }
+  return $paths[$lang];
 }
 
 /**
@@ -479,7 +529,7 @@ function i18n_get_normal_path($path) {
   $prefix = i18n_get_lang_prefix($path, TRUE);
   if(!$prefix || _i18n_is_bootstrap()){
     // If bootstrap, drupal_lookup_path is not defined
-    return $path; 
+    return $path;
   } // First, check alias with lang
   elseif($alias = drupal_lookup_path('source', $prefix.'/'.$path)){
     i18n_get_lang_prefix($alias, TRUE); // In case alias has language
@@ -488,7 +538,7 @@ function i18n_get_normal_path($path) {
   elseif($alias = drupal_lookup_path('source', $path)){
     i18n_get_lang_prefix($alias, TRUE);
     return $alias;
-  } 
+  }
   else {
     return $path;
   }
@@ -502,20 +552,37 @@ function i18n_get_normal_path($path) {
  * Produces i18n paths, with language prefix
  * If path is empty or site frontpage, path = 'lang'
  * Check for frontpage and search for alias before adding language
+ *
+ * @param string $path
+ *  Drupal Path
+ * @param string $lang
+ *  Language prefix
+ *
+ * @return string
+ *  Drupal path with language prefix.
  */
 function i18n_path($path, $lang) {
-  if (!$path || $path == i18n_frontpage($lang)) {
-    return $lang;
-  } elseif($alias = drupal_lookup_path('alias', $path)) {
-	  if($prefix = i18n_get_lang_prefix($alias)) {
-      // This alias will be valid only if it has the same language
-	    return ($prefix == $lang) ? $alias : $lang.'/'.$path;
-	  } else { // Alias without language prefix
-	    return $lang.'/'.$alias;
-	  }
-  } else { // Alias for language path will be searched later
-    return $lang.'/'.$path;  
-  } 
+  $temp = @trim($path, '/');
+  $lang = ($lang = @trim($lang)) ? $lang : i18n_get_lang();
+  $bool = (!variable_get('i18n_prefix_default', 0) && $cur_lang == $lang);
+  $def_lang  = i18n_default_language();
+  $frontpage = i18n_frontpage($lang);
+  if (!$path || $path == $frontpage || !$temp || $temp == $frontpage) {
+    $path = $bool ? i18n_url_rewrite('alias', $path, $path) : $lang;
+    $path = @trim($path, '/');
+    return $path;
+  }
+  if(($alias = drupal_lookup_path('alias', $path))) {
+    if ($lang == i18n_get_lang_prefix($alias)) {
+      i18n_get_lang_prefix($alias, TRUE); // Alias without language prefix
+    } else {
+      $alias = i18n_url_rewrite('alias', $alias, $path);
+    }
+    $path = $alias;
+  }
+  $path = $bool ? $path : $lang .'/'. $path;
+  $path = @trim($path, '/');
+  return $path;
 }
 
 /**
@@ -528,7 +595,7 @@ function i18n_node_get_lang($nid, $defau
 
 /**
  * Get allowed languages for node
- * 
+ *
  * This allows node types to define its own language list implementing hook 'language_list'
  */
 function i18n_node_language_list($node) {
@@ -551,9 +618,9 @@ function i18n_get_main_lang($lang = NULL
 
 /**
  * Function i18n_get_links
- * 
+ *
  * Returns an array of links for all languages, with or without names/flags
- * 
+ *
  * @param $path
  *   Drupal internal path
  * @param $query
@@ -569,7 +636,7 @@ function i18n_get_links($path = '', $que
   foreach (array_keys(i18n_supported_languages()) as $lang){
     $links[$lang]= theme('i18n_link', $names[$lang], i18n_path($path, $lang), $lang, $query);
   }
-  return $links;  
+  return $links;
 }
 
 /**
@@ -597,14 +664,14 @@ function _i18n_locale_supported_language
 function _i18n_goto($lang){
   if(!function_exists('drupal_goto')){
     require_once './includes/common.inc';
-    require_once './includes/path.inc';   
+    require_once './includes/path.inc';
   }
   drupal_goto($lang);
 }
 
 /**
  * i18n_selection_mode
- * 
+ *
  * Allows several modes for query rewriting and to change them programatically
  * 	off = No language conditions inserted
  * 	simple = Only current language and no language
@@ -620,7 +687,7 @@ function i18n_selection_mode($mode= NULL
   static $current_mode = 'simple';
   static $current_value = '';
   static $store = array();
-  
+
   if(!$mode) {
     return $current_mode;
   } elseif($mode == 'params'){
@@ -632,16 +699,16 @@ function i18n_selection_mode($mode= NULL
     array_push($store, array($current_mode, $current_value));
     $current_mode = $mode;
     $current_value = $params;
-  } 
+  }
 }
 // List of selection modes
 function _i18n_selection_mode(){
   return array(
     'simple' => t('Only current language and no language'),
     'mixed' => t('Only current and default languages and no language'),
-    'default' => t('Only default language and no language'),    
+    'default' => t('Only default language and no language'),
     'strict' => t('Only current language'),
-    'off' => t('All content. No language conditions apply'),    
+    'off' => t('All content. No language conditions apply'),
   );
 }
 // List of language support modes for content
@@ -657,7 +724,7 @@ function _i18n_content_languages() {
  * @name Themeable functions
  * @{
  */
-  
+
 /**
  * Produces a language link with the right flag
  */
@@ -673,7 +740,7 @@ function theme_i18n_link($text, $target,
 
 /**
  * Theme language icon
- * 
+ *
  * This function can be overridden for no language icons
  */
 function theme_i18n_language_icon($lang){
@@ -683,14 +750,14 @@ function theme_i18n_language_icon($lang)
     list($width, $height) = explode('x', variable_get('i18n_icon_size', '16x12'));
     $attribs = array('class' => 'i18n-icon', 'width' => $width, 'height' => $height, 'alt' => $languages[$lang]);
     return "<img src=\"$src\" ".drupal_attributes($attribs)." />";
-  }  
+  }
 }
 
 /* @} */
 
 /**
  * Implementation of conf_url_rewrite
- * 
+ *
  * This is a conditional definition, just in case it is defined somewhere else.
  * If so, path rewriting won't work properly but at least it won't break Drupal
  */
@@ -699,25 +766,45 @@ if(!function_exists('custom_url_rewrite'
   function custom_url_rewrite($type, $path, $original) {
     return i18n_url_rewrite($type, $path, $original);
   }
-}  
+}
 
 /**
- * Rewrites path with current language and removes prefix if searching for source path
+ * Rewrites path with current language and removes
+ * prefix if searching for source path
+ *
+ * @param string $type
+ * @param string $path
+ * @param string $original
+ *
+ * @return string
  */
 function i18n_url_rewrite($type, $path, $original){
-  if ($type == 'alias' && !i18n_get_lang_prefix($path) ){
-    return $path ? i18n_get_lang() . '/'. $path : i18n_get_lang();
-  } elseif ($type == 'source') {
+  if ($type == 'alias') {
+    $def_lang = i18n_default_language();
+    $cur_lang = i18n_get_lang();
+    $pre_lang = i18n_get_lang_prefix($path, TRUE);
+    $bool = (!variable_get('i18n_prefix_default', 0) && $cur_lang == $def_lang);
+    if ($pre_lang) {
+    	$path = ($pre_lang == $def_lang)
+    	      ? ($bool ? $path : $pre_lang .'/'. $path)
+    	      : ($pre_lang .'/'. $path);
+    } else {
+    	$path = ($bool)
+    	      ? ($path)
+    	      : ($path ? $cur_lang . '/'. $path : $cur_lang);
+    }
+    $path = trim($path, '/');
+  }
+  elseif ($type == 'source') {
     if ($path == $original) {
-      return i18n_get_normal_path($path);
-    } else { // Path may have been dealiased but still have language prefix
-      i18n_get_lang_prefix($path, TRUE);
-      return $path;
+    	$path = i18n_get_normal_path($path);
+    } else {
+    	// Path may have been dealiased but still have language prefix
+    	i18n_get_lang_prefix($path, TRUE);
     }
-  } else {
-    return $path;
   }
-} 
+  return $path;
+}
 
 /**
  * Implementation of hook_db_rewrite_sql()
@@ -735,12 +822,12 @@ function i18n_db_rewrite_sql($query, $pr
     case 'n':
     case 'node':
     case 'nc': // For node_comment table, added in 5.2
-      // Node queries. 
+      // Node queries.
       // When loading specific nodes, language conditions shouldn't apply
       if (preg_match("/WHERE.*\s$primary_table.nid\s*=\s*(\d|%d)/", $query)) return;
       // If language conditions already there, get out
       if (preg_match("/i18n/", $query)) return;
-      
+
       $result['join'] = "LEFT JOIN {i18n_node} i18n ON $primary_table.nid = i18n.nid";
       $result['where'] = i18n_db_rewrite_where('i18n', $mode);
       return $result;
@@ -780,7 +867,7 @@ function i18n_db_rewrite_where($alias, $
       return "$alias.language ='".i18n_default_language()."' OR $alias.language ='' OR $alias.language IS NULL" ;
     case 'custom':
       return str_replace('%alias', $alias, i18n_selection_mode('params'));
-  }  
+  }
 }
 
 /**
@@ -792,7 +879,7 @@ function i18n_exit(){
 
 /**
  * Implementation of hook_form_alter
- * 
+ *
  * This is the place to add language fields to all forms
  */
 function i18n_form_alter($form_id, &$form) {
@@ -808,18 +895,18 @@ function i18n_form_alter($form_id, &$for
     case 'taxonomy_form_vocabulary': // Taxonomy vocabulary
       if(isset($form['vid'])) {
         $vocabulary = taxonomy_get_vocabulary($form['vid']['#value']);
-      } 
+      }
       $form['i18n'] = array('#type' => 'fieldset', '#title' => t('Multilingual options'), '#collapsible' => TRUE, '#weight' => -20);
-      $form['i18n']['language'] = _i18n_language_select(isset($vocabulary) ? $vocabulary->language : i18n_get_lang(),t('This language will be set for all terms in this vocabulary')); 
+      $form['i18n']['language'] = _i18n_language_select(isset($vocabulary) ? $vocabulary->language : i18n_get_lang(),t('This language will be set for all terms in this vocabulary'));
       break;
-      
+
     case 'taxonomy_form_term': // Taxonomy term
       if(isset($form['tid']) && is_numeric($form['tid']['#value'])) {
         $term = taxonomy_get_term($form['tid']['#value']);
-      } 
+      }
       $form['language'] = _i18n_language_select(isset($term) ? $term->language : i18n_get_lang());
       break;
-     
+
      case 'node_type_form':
        $node_type = $form['old_type']['#value'];
        // Build a fieldset to allow some more options here
@@ -847,7 +934,7 @@ function i18n_form_alter($form_id, &$for
             '#size' => 15,
             '#maxlength' => 64,
           );
-        }   
+        }
         $form['rtl'] = array(
           '#type' => 'checkboxes',
           '#options' => $options,
@@ -865,9 +952,9 @@ function i18n_form_alter($form_id, &$for
       } else {
         $language = '';
       }
-      $form['language'] = _i18n_language_select($language, t('You can set a language for this menu item.')); 
+      $form['language'] = _i18n_language_select($language, t('You can set a language for this menu item.'));
       $form['#submit'] = array('i18n_menu_edit_item_form_submit' => array());
-      break;   
+      break;
     default:
       // Node edit form
       if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id && $node = $form['#node']) {
@@ -897,12 +984,12 @@ function i18n_form_alter($form_id, &$for
           $form['#submit'] = array('i18n_variable_form_submit' => array());
         }
       }
-  }    
+  }
 }
 
 /**
  * Implementation of hook_perm().
- * 
+ *
  * Permissions defined
  * - administer all languages
  *   Disables language conditions for administration pages, so the user can view objects for all languages at the same time.
@@ -948,7 +1035,7 @@ function i18n_admin_manage_screen_submit
   $save['name']['en'] = 'English';
   $languages = locale_supported_languages(FALSE, TRUE);
   foreach($languages['name'] as $key => $lang) {
-   // Nothing 
+   // Nothing
   }
   variable_set('i18n_languages', $save);
 }
@@ -988,7 +1075,7 @@ function i18n_variable_form_submit($form
         i18n_variable_set($key, $value, $language);
       }
       unset($form_values[$key]);
-    } 
+    }
   }
   // Re-submit form
   system_settings_form_submit($form_id, $form_values);
@@ -996,7 +1083,7 @@ function i18n_variable_form_submit($form
 
 /**
  * Initialization of multilingual variables
- * 
+ *
  * @param $language
  *   Language to retrieve variables. Defaults to current language
  * @param $prefix
@@ -1075,10 +1162,10 @@ function _i18n_get_lang() {
   }
   // Language not set, find one
   $languages = i18n_supported_languages();
-  
+
   if ($i18n_langpath && array_key_exists($i18n_langpath,$languages)) {
     // Sets session language only when language is in path, not for other cases
-    $_SESSION['language'] = $i18n_lang = $i18n_langpath;  
+    $_SESSION['language'] = $i18n_lang = $i18n_langpath;
   }
   elseif (isset($_SESSION['language']) && array_key_exists($_SESSION['language'], $languages)) {
     $i18n_lang = $_SESSION['language'];
@@ -1113,7 +1200,7 @@ function _i18n_language_select($value ='
 /**
  * Load language variables into array
  */
-function _i18n_variable_init($language, $prefix = ''){  
+function _i18n_variable_init($language, $prefix = ''){
   $variables = array();
   $cacheid = 'variables:'.$language.($prefix ? ':'.$prefix : '');
   if ($cached = cache_get($cacheid)) {
@@ -1155,10 +1242,10 @@ function _i18n_variable_exit(){
 
 /**
  * Check whether we are in bootstrap mode
- */  
+ */
 function _i18n_is_bootstrap(){
   return !function_exists('drupal_get_headers');
-}    
+}
 
 /**
  * Sets db_prefix to given language
@@ -1171,7 +1258,7 @@ function _i18n_set_db_prefix($lang) {
 }
 
 /**
- * To get the original path. 
+ * To get the original path.
  * Cannot use $_GET["q"] cause it may have been already changed
  */
 function _i18n_get_original_path() {
