1 language.install language_update_1001()

Convert language settings to config.

Related topics

File

core/modules/language/language.install, line 115
Install, update and uninstall functions for the language module.

Code

function language_update_1001() {
  // Save the always-required settings in system.core config.
  $default_language = update_variable_get('language_default', (object) array(
    'langcode' => 'en',
    'name' => 'English',
    'direction' => 0,
    'enabled' => TRUE,
    'weight' => 0,
  ));
  $core_config = config('system.core');

  // The default language setting used to be an object, now it's just langcode.
  $core_config->set('language_default', $default_language->langcode);
  $core_config->set('language_count', update_variable_get('language_count'));
  $core_config->save();

  // Save settings required for language.module into its own file.
  $language_config = config('language.settings');
  $language_config->set('_config_static', TRUE);

  // Negotiation options previously contained information from
  // hook_language_negotiation_info() as a cache, now we just store the order.
  $negotiation = array(
    'language_content' => array(),
    'language' => array(),
    'language_url' => array(),
  );
  foreach ($negotiation as $language_type => $negotiation_data) {
    $negotiation_data = update_variable_get('language_negotiation_' . $language_type, array());
    $negotiation[$language_type] = array_keys($negotiation_data);
  }
  array_filter($negotiation);
  $language_config->set('language_negotiation', $negotiation);

  $language_config->save();

  // Delete the old variables.
  update_variable_del('language_default');
  update_variable_del('language_count');
  update_variable_del('language_negotiation_language_content');
  update_variable_del('language_negotiation_language');
  update_variable_del('language_negotiation_language_url');

  // The language_types variable is no longer used in Backdrop.
  update_variable_del('language_types');
}