1 update.inc | update_prepare_language() |
Prepare Backdrop language changes for the bootstrap if needed.
File
- core/
includes/ update.inc, line 217 - Backdrop site update API.
Code
function update_prepare_language() {
if (db_table_exists('languages')) {
$languages = db_select('languages', 'l')
->fields('l')
->execute();
$plurals = array();
$javascript = array();
$prefixes = array();
$domains = array();
foreach ($languages as $language) {
$plurals[$language->language] = array(
'plurals' => $language->plurals,
'formula' => $language->formula,
);
$javascript[$language->language] = $language->javascript;
$prefixes[$language->language] = $language->prefix;
$domains[$language->language] = $language->domain;
}
state_set('locale_translation_plurals', $plurals);
state_set('locale_translation_javascript', $javascript);
config_set('locale.settings', 'language_negotiation_url_prefixes', $prefixes);
config_set('locale.settings', 'language_negotiation_url_domains', $domains);
// Drop now unneeded columns.
db_drop_field('languages', 'plurals');
db_drop_field('languages', 'formula');
db_drop_field('languages', 'javascript');
db_drop_field('languages', 'prefix');
db_drop_field('languages', 'domain');
db_drop_field('languages', 'native');
// Rename the languages table to language.
db_rename_table('languages', 'language');
// Finally install/enable the language module. We need to use the update
// specific version of this function to ensure schema conflicts don't happen
// due to our updated data.
$modules = array('language');
update_module_add_to_system($modules);
update_module_enable($modules);
// Rename 'language' column to 'langcode'.
require_once BACKDROP_ROOT . '/core/modules/language/language.install';
language_update_1000();
}
}