Index: bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.172
diff -u -r1.172 bootstrap.inc
--- bootstrap.inc	15 Jun 2007 06:45:05 -0000	1.172
+++ bootstrap.inc	29 Jun 2007 10:16:17 -0000
@@ -424,11 +424,33 @@
  *   The name of the variable to return.
  * @param $default
  *   The default value to use if this variable has never been set.
+ * @param $langcode
+ *   The language code to get the value for. Defaults to the code of the
+ *   language used on the page, but then falls back to the global variable
+ *   if a language specific is not found. Set it to empty to explicitly
+ *   ask for a global variable.
  * @return
  *   The value of the variable.
  */
-function variable_get($name, $default) {
-  global $conf;
+function variable_get($name, $default, $langcode = NULL) {
+  global $conf, $language;
+
+  // Before language_init, $language is empty.
+  if (!empty($language)) {
+    // -1 is not possible as a language code, but it's the default,
+    // and we override that with the current language.
+    if (!$langcode) {
+      $langcode = $language->language;
+    }
+    elseif (!isset($conf[$langcode])) {
+      // This will allow any module to define language_variable_init() and localize variables.
+      // Variables used before module loading cannot be localized though.
+      $conf[$langcode] = function_exists('language_variable_init') ? language_variable_init($langcode) : array();
+    }
+    if (isset($conf[$langcode][$name])) {
+      return $conf[$langcode][$name];
+    }
+  }
 
   return isset($conf[$name]) ? $conf[$name] : $default;
 }
