Commit 97c14a99 authored by Dries's avatar Dries

- Patch #642782 by plach, Dave Reid, greggles, mfb: hook_language_init() is a...

- Patch #642782 by plach, Dave Reid, greggles, mfb: hook_language_init() is a bootstrap hook and needs bootstrap_invoke_all().
parent 8173fc1a
......@@ -859,10 +859,10 @@ function drupal_page_is_cacheable($allow_caching = NULL) {
}
/**
* Call all init or exit hooks without including all modules.
* Invoke a bootstrap hook in all bootstrap modules that implement it.
*
* @param $hook
* The name of the bootstrap hook we wish to invoke.
* The name of the bootstrap hook to invoke.
*/
function bootstrap_invoke_all($hook) {
// _drupal_bootstrap_page_cache() already loaded the bootstrap modules, so we
......@@ -1163,7 +1163,7 @@ function drupal_serve_page_from_cache(stdClass $cache) {
* Define the critical hooks that force modules to always be loaded.
*/
function bootstrap_hooks() {
return array('boot', 'exit', 'watchdog');
return array('boot', 'exit', 'watchdog', 'language_init');
}
/**
......@@ -2086,7 +2086,7 @@ function drupal_language_initialize() {
}
// Allow modules to react on language system initialization in multilingual
// environments.
module_invoke_all('language_init', $types);
bootstrap_invoke_all('language_init');
}
}
......
......@@ -24,6 +24,33 @@ function hook_locale($op = 'groups') {
}
}
/**
* Allows modules to act after language initialization has been performed.
*
* This is primarily needed to provide translation for configuration variables
* in the proper bootstrap phase. Variables are user-defined strings and
* therefore should not be translated via t(), since the source string can
* change without notice and any previous translation would be lost. Moreover,
* since variables can be used in the bootstrap phase, we need a bootstrap hook
* to provide a translation early enough to avoid misalignments between code
* using the original values and code using the translated values. However
* modules implementing hook_boot() should be aware that language initialization
* did not happen yet and thus they cannot rely on translated variables.
*/
function hook_language_init() {
global $language, $conf;
switch ($language->language) {
case 'it':
$conf['site_name'] = 'Il mio sito Drupal';
break;
case 'fr':
$conf['site_name'] = 'Mon site Drupal';
break;
}
}
/**
* Perform alterations on language switcher links.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment