diff --git a/core/modules/language/language.install b/core/modules/language/language.install index ecf637d..92c61f4 100644 --- a/core/modules/language/language.install +++ b/core/modules/language/language.install @@ -7,10 +7,34 @@ /** * Implements hook_install(). + * + * Enable URL language negotiation by default in order to have a basic working + * system on multilingual sites without needing any preliminary configuration. */ function language_install() { // Add the default language to the database too. language_save(language_default()); + + require_once DRUPAL_ROOT . '/core/includes/language.inc'; + + // We cannot rely on language negotiation hooks here, because locale module is + // not enabled yet. Therefore language_negotiation_set() cannot be used. + $info = language_negotiation_info(); + $method = $info[LANGUAGE_NEGOTIATION_URL]; + $method_fields = array('callbacks', 'file', 'cache'); + $negotiation = array(); + + // Store only the needed data. + foreach ($method_fields as $field) { + if (isset($method[$field])) { + $negotiation[LANGUAGE_NEGOTIATION_URL][$field] = $method[$field]; + } + } + + // Enable URL language detection for each (core) configurable language type. + foreach (language_types_get_configurable() as $type) { + variable_set("language_negotiation_$type", $negotiation); + } } /** @@ -21,6 +45,20 @@ function language_uninstall() { variable_del('language_default'); variable_del('language_count'); + // Clear variables. + variable_del('language_types'); + variable_del('language_negotiation_url_part'); + variable_del('language_negotiation_url_prefixes'); + variable_del('language_negotiation_url_domains'); + variable_del('language_negotiation_session_param'); + variable_del('language_content_type_default'); + variable_del('language_content_type_negotiation'); + + foreach (language_types_get_all() as $type) { + variable_del("language_negotiation_$type"); + variable_del("language_negotiation_methods_weight_$type"); + } + // Re-initialize the language system so successive calls to t() and other // functions will not expect languages to be present. drupal_language_initialize(); diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install index d05d24b..3c96d8d 100644 --- a/core/modules/locale/locale.install +++ b/core/modules/locale/locale.install @@ -6,62 +6,6 @@ */ /** - * Implements hook_install(). - * - * Enable URL language negotiation by default in order to have a basic working - * system on multilingual sites without needing any preliminary configuration. - */ -function locale_install() { - require_once DRUPAL_ROOT . '/core/includes/language.inc'; - - // We cannot rely on language negotiation hooks here, because locale module is - // not enabled yet. Therefore language_negotiation_set() cannot be used. - $info = locale_language_negotiation_info(); - $method = $info[LANGUAGE_NEGOTIATION_URL]; - $method_fields = array('callbacks', 'file', 'cache'); - $negotiation = array(); - - // Store only the needed data. - foreach ($method_fields as $field) { - if (isset($method[$field])) { - $negotiation[LANGUAGE_NEGOTIATION_URL][$field] = $method[$field]; - } - } - - // Enable URL language detection for each (core) configurable language type. - foreach (language_types_get_configurable() as $type) { - variable_set("language_negotiation_$type", $negotiation); - } -} - -/** - * Fill in the path prefixes and domains when enabled. - * - * Language module might change the list of languages, so we need to sync our - * configuration for domains and paths with the current language list. This - * should run every time the module is enabled. - */ -function locale_enable() { - require_once DRUPAL_ROOT . '/core/includes/locale.inc'; - - $languages = language_list(); - $prefixes_old = locale_language_negotiation_url_prefixes(); - $domains_old = locale_language_negotiation_url_domains(); - - $prefixes = array(); - $domains = array(); - foreach ($languages as $langcode => $language) { - // Keep the old prefix or fill in based on whether the language is default. - $prefixes[$langcode] = empty($prefixes_old[$langcode]) ? (empty($language->default) ? $langcode : '') : $prefixes_old[$langcode]; - // Keep the old domain or fill in empty value. - $domains[$langcode] = empty($domains_old[$langcode]) ? '' : $domains_old[$langcode]; - } - - locale_language_negotiation_url_prefixes_save($prefixes); - locale_language_negotiation_url_domains_save($domains); -} - -/** * Implements hook_uninstall(). */ function locale_uninstall() { @@ -82,13 +26,6 @@ function locale_uninstall() { } // Clear variables. - variable_del('language_types'); - variable_del('locale_language_negotiation_url_part'); - variable_del('locale_language_negotiation_url_prefixes'); - variable_del('locale_language_negotiation_url_domains'); - variable_del('locale_language_negotiation_session_param'); - variable_del('language_content_type_default'); - variable_del('language_content_type_negotiation'); variable_del('locale_cache_strings'); variable_del('locale_js_directory'); variable_del('javascript_parsed'); @@ -97,11 +34,6 @@ function locale_uninstall() { variable_del('locale_translation_plurals'); variable_del('locale_translation_javascript'); - foreach (language_types_get_all() as $type) { - variable_del("language_negotiation_$type"); - variable_del("locale_language_negotiation_methods_weight_$type"); - } - // Remove all node type language variables. Node module might have been // enabled, but may be disabled, so use a wildcard delete. db_delete('variable')