diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index b8d1a26..fee74db 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -690,6 +690,10 @@ function install_tasks($install_state) { ), 'install_profile_themes' => array( ), + 'install_download_additional_translations' => array( + 'type' => 'batch', + 'run' => $needs_translations ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP, + ), 'install_import_translations' => array( 'display_name' => t('Set up translations'), 'display' => $needs_translations, @@ -1538,16 +1542,16 @@ function install_profile_themes(&$install_state) { } /** - * Imports languages via a batch process during installation. + * Prepares the system for import and downloads additional translations. * * @param $install_state * An array of information about the current installation state. * * @return - * The batch definition, if there are language files to import. + * The batch definition, if there are language files to download. */ -function install_import_translations(&$install_state) { - include_once __DIR__ . '/../modules/locale/locale.bulk.inc'; +function install_download_additional_translations(&$install_state) { + \Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc'); $langcode = $install_state['parameters']['langcode']; if (!($language = entity_load('configurable_language', $langcode))) { @@ -1565,17 +1569,39 @@ function install_import_translations(&$install_state) { // If there is more than one language or the single one is not English, we // should download/import translations. $languages = \Drupal::languageManager()->getLanguages(); - if (count($languages) > 1 || !isset($languages['en'])) { - foreach($languages as $langcode => $language) { - // The installer language was already downloaded. Check downloads for the - // other languages if any. Ignore any download errors here, since we - // are in the middle of an install process and there is no way back. We - // will not import what we cannot download. - if ($langcode != $install_state['parameters']['langcode']) { - install_check_translations($langcode, $install_state['server_pattern']); - } + $operations = array(); + foreach($languages as $langcode => $language) { + // The installer language was already downloaded. Check downloads for the + // other languages if any. Ignore any download errors here, since we + // are in the middle of an install process and there is no way back. We + // will not import what we cannot download. + if ($langcode != 'en' && $langcode != $install_state['parameters']['langcode']) { + $operations[] = array('install_check_translations', array($langcode, $install_state['server_pattern'])); } + } + if (count($operations)) { + return array( + 'operations' => $operations, + 'title' => t('Downloading additional translations'), + 'error_message' => t('The installation has encountered an error.'), + ); + } +} +/** + * Imports languages via a batch process during installation. + * + * @param $install_state + * An array of information about the current installation state. + * + * @return + * The batch definition, if there are language files to import. + */ +function install_import_translations(&$install_state) { + // If there is more than one language or the single one is not English, we + // should import translations. + $languages = \Drupal::languageManager()->getLanguages(); + if (count($languages) > 1 || !isset($languages['en'])) { // Set up a batch to import translations. _install_prepare_import(array_keys($languages), $install_state['server_pattern']); module_load_include('fetch.inc', 'locale'); @@ -1594,6 +1620,7 @@ function install_import_translations(&$install_state) { * Server access pattern (to replace language code, version number, etc. in). */ function _install_prepare_import($langcodes, $server_pattern) { + \Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc'); $matches = array(); foreach ($langcodes as $langcode) { @@ -1641,8 +1668,8 @@ function _install_prepare_import($langcodes, $server_pattern) { * The batch definition, if there are language files to import. */ function install_import_translations_remaining(&$install_state) { - module_load_include('fetch.inc', 'locale'); - module_load_include('compare.inc', 'locale'); + \Drupal::moduleHandler()->loadInclude('locale', 'fetch.inc'); + \Drupal::moduleHandler()->loadInclude('locale', 'compare.inc'); // Build a fresh list of installed projects. When more projects than core are // installed, their translations will be downloaded (if required) and imported diff --git a/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageForeignTest.php b/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageForeignTest.php index 183fce9..248d485 100644 --- a/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageForeignTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageForeignTest.php @@ -7,8 +7,6 @@ namespace Drupal\system\Tests\Installer; -use Drupal\simpletest\InstallerTestBase; - /** * Tests translation files for multiple languages get imported during install. *