diff -u b/core/profiles/demo_umami/demo_umami.info.yml b/core/profiles/demo_umami/demo_umami.info.yml --- b/core/profiles/demo_umami/demo_umami.info.yml +++ b/core/profiles/demo_umami/demo_umami.info.yml @@ -45,7 +45,8 @@ + - language + - locale - config_translation - content_translation - - locale - - language themes: - seven - umami +keep_english: true only in patch2: unchanged: --- a/core/profiles/demo_umami/demo_umami.install +++ b/core/profiles/demo_umami/demo_umami.install @@ -34,6 +34,9 @@ function demo_umami_requirements($phase) { * @see system_install() */ function demo_umami_install() { + // Ensure the translation fields are created in the database. + \Drupal::service('entity.definition_update_manager')->applyUpdates(); + // Assign user 1 the "administrator" role. $user = User::load(1); $user->roles[] = 'administrator'; only in patch2: unchanged: --- a/core/profiles/demo_umami/demo_umami.profile +++ b/core/profiles/demo_umami/demo_umami.profile @@ -7,6 +7,7 @@ use Drupal\contact\Entity\ContactForm; use Drupal\Core\Form\FormStateInterface; +use Symfony\Component\Yaml\Parser; /** * Implements hook_form_FORM_ID_alter() for install_configure_form(). @@ -18,6 +19,66 @@ function demo_umami_form_install_configure_form_alter(&$form, FormStateInterface $form['#submit'][] = 'demo_umami_form_install_configure_submit'; } +/** + * Implements hook_install_tasks(). + */ +function demo_umami_install_tasks(&$install_state) { + return array( + 'demo_umami_install_import_language_config' => array(), + ); +} + +/** + * Implements hook_install_tasks_alter(). + */ +function demo_umami_install_tasks_alter(&$tasks, $install_state) { + // Moves the language config import task to the end of the install tasks so + // that it is run after the final import of languages. + $task = $tasks['demo_umami_install_import_language_config']; + unset($tasks['demo_umami_install_import_language_config']); + $tasks = array_merge($tasks, array('demo_umami_install_import_language_config' => $task)); +} + +/** + * Imports language configuration overrides. + */ +function demo_umami_install_import_language_config() { + $language_manager = \Drupal::languageManager(); + $yaml_parser = new Parser(); + // The language code of the default locale. + $site_default_langcode = $language_manager->getDefaultLanguage()->getId(); + // The directory where the language config files reside. + $language_config_directory = __DIR__ . '/config/install/language'; + // Sub-directory names (language codes). + // The language code of the default language is excluded. If the user + // chooses to install in Hungarian, French, or Spanish, the language config is + // imported by core and the user has the chance to override it during the + // installation process. + $langcodes = array_diff(scandir($language_config_directory), array('..', '.', $site_default_langcode)); + + foreach ($langcodes as $langcode) { + // All .yml files in the language's config subdirectory. + $config_files = glob("$language_config_directory/$langcode/*.yml"); + + foreach ($config_files as $file_name) { + // Information from the .yml file as an array. + $yaml = $yaml_parser->parse(file_get_contents($file_name)); + // Uses the base name of the .yml file to get the config name. + $config_name = basename($file_name, '.yml'); + // The language configuration object. + $config = $language_manager->getLanguageConfigOverride($langcode, $config_name); + + foreach ($yaml as $config_key => $config_value) { + // Updates the configuration object. + $config->set($config_key, $config_value); + } + + // Saves the configuration. + $config->save(); + } + } +} + /** * Submission handler to sync the contact.form.feedback recipient. */