Index: includes/language.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/language.inc,v retrieving revision 1.19 diff -u -r1.19 language.inc --- includes/language.inc 1 Feb 2009 16:45:53 -0000 1.19 +++ includes/language.inc 3 Feb 2009 12:05:05 -0000 @@ -142,3 +142,23 @@ } } } + +/** + * Return array of localized variables from modules. + * + * This will only work after modules have been loaded, thus variables used + * before module loading won't be localized. + */ +function language_variable_init($langcode) { + if ((variable_get('language_count', 1) == 1)) { + return array(); + } + if ($cached = cache_get('variables:'.$langcode, 'cache')) { + $variables = $cached->data; + } + else { + $variables = module_invoke_all('variable_init', $langcode); + cache_set('variables:'.$langcode, $variables); + } + return $variables; +} \ No newline at end of file Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.269 diff -u -r1.269 bootstrap.inc --- includes/bootstrap.inc 31 Jan 2009 16:50:56 -0000 1.269 +++ includes/bootstrap.inc 3 Feb 2009 12:05:05 -0000 @@ -628,11 +628,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 = NULL) { - global $conf; +function variable_get($name, $default = NULL, $langcode = NULL) { + global $conf, $language; + + // Before language_init, $language is empty. + if (!empty($language)) { + // If no language code, default to current language + if (!$langcode) { + $langcode = $language->language; + } + elseif (!isset($conf[$langcode])) { + // This will only happen when variable_get() is called with a language code. + // So it must be from a module, not during bootstrap. + $conf[$langcode] = language_variable_init($langcode); + } + if (isset($conf[$langcode][$name])) { + return $conf[$langcode][$name]; + } + } + return isset($conf[$name]) ? $conf[$name] : $default; } @@ -1117,7 +1139,7 @@ } function _drupal_bootstrap($phase) { - global $conf, $user; + global $conf, $user, $language; switch ($phase) { @@ -1228,6 +1250,10 @@ case DRUPAL_BOOTSTRAP_FULL: require_once DRUPAL_ROOT . '/includes/common.inc'; _drupal_bootstrap_full(); + // Load variables for current language + if (function_exists('language_variable_init')) { + $conf[$language->language] = language_variable_init($language->language); + } break; } }