1 locale.install locale_enable()

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.

File

core/modules/locale/locale.install, line 38
Install, update and uninstall functions for the locale module.

Code

function locale_enable() {
  require_once BACKDROP_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);

  // When enabling locale go through all config files and add translatables.
  $active_storage = config_get_config_storage('active');
  $names = $active_storage->listAll();

  foreach ($names as $name) {
    $config = config($name);
    if ($config->get('_config_translatables') !== NULL) {
      foreach ($config->get('_config_translatables') as $translatable) {
        $translation = locale($config->get($translatable), 'config:' . $name . ':' . $translatable);
      }
    }
  }
}