diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 48cc8fe50f922840566a4e8198d0a00c13759816..c398611698d16ceaad35641549fe86d8a5126431 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -758,7 +758,8 @@ function install_tasks($install_state) { // 'install_import_translations' task. Import when a non-English language is // available and selected. Also we will need translations even if the // installer language is English but there are other languages on the system. - $needs_translations = (count($install_state['translations']) > 1 && !empty($install_state['parameters']['langcode']) && $install_state['parameters']['langcode'] != 'en') || \Drupal::languageManager()->isMultilingual(); + $locale_module_installed = \Drupal::moduleHandler()->moduleExists('locale'); + $needs_translations = $locale_module_installed && ((count($install_state['translations']) > 1 && !empty($install_state['parameters']['langcode']) && $install_state['parameters']['langcode'] != 'en') || \Drupal::languageManager()->isMultilingual()); // Determine whether a translation file must be downloaded during the // 'install_download_translation' task. Download when a non-English language // is selected, but no translation is yet in the translations directory. diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php new file mode 100644 index 0000000000000000000000000000000000000000..54a9fc13361f4ad4f4c3118f0a8425730698e0e3 --- /dev/null +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php @@ -0,0 +1,72 @@ +<?php + +namespace Drupal\FunctionalTests\Installer; + +use Drupal\Core\Serialization\Yaml; + +/** + * Tests installing a profile with non-English language and no locale module. + * + * @group Installer + */ +class InstallerNonEnglishProfileWithoutLocaleModuleTest extends InstallerTestBase { + + /** + * The testing profile name. + * + * @var string + */ + const PROFILE = 'testing_with_language_without_locale'; + + /** + * {@inheritdoc} + */ + protected $profile = self::PROFILE; + + /** + * {@inheritdoc} + */ + protected function prepareEnvironment() { + parent::prepareEnvironment(); + + // Create a self::PROFILE testing profile that depends on the 'language' + // module but not on 'locale' module. + $profile_info = [ + 'type' => 'profile', + 'core' => \Drupal::CORE_COMPATIBILITY, + 'name' => 'Test with language but without locale', + 'install' => ['language'], + ]; + + // File API functions are not available yet. + $profile_dir = "{$this->root}/{$this->siteDirectory}/profiles/" . self::PROFILE; + $profile_config_dir = "$profile_dir/config/install"; + mkdir($profile_config_dir, 0777, TRUE); + $profile_info_file = $profile_dir . '/' . static::PROFILE . '.info.yml'; + file_put_contents($profile_info_file, Yaml::encode($profile_info)); + + // Copy a non-English language config YAML to be installed with the profile. + copy($this->root . '/core/profiles/testing_multilingual/config/install/language.entity.de.yml', $profile_config_dir . '/language.entity.de.yml'); + } + + /** + * Tests installing a profile with non-English language and no locale module. + */ + public function testNonEnglishProfileWithoutLocaleModule() { + $this->assertSession()->statusCodeEquals(200); + $this->assertUrl('user/1'); + // Confirm that we are logged-in after installation. + $this->assertText($this->rootUser->getAccountName()); + + // Verify that the confirmation message appears. + require_once $this->root . '/core/includes/install.inc'; + $this->assertRaw(t('Congratulations, you installed @drupal!', [ + '@drupal' => drupal_install_profile_distribution_name(), + ])); + + $this->assertFalse(\Drupal::service('module_handler')->moduleExists('locale'), 'The Locale module is not installed.'); + $this->assertTrue(\Drupal::service('module_handler')->moduleExists('language'), 'The Language module is installed.'); + $this->assertTrue(\Drupal::languageManager()->isMultilingual(), 'The language manager is multi-lingual.'); + } + +}