Loading core/includes/install.core.inc +11 −17 Original line number Diff line number Diff line Loading @@ -1397,8 +1397,8 @@ function install_download_translation(&$install_state) { // Check whether all conditions are met to download. Download the translation // if possible. $requirements = install_check_translations($install_state['parameters']['langcode'], $install_state['server_pattern']); // Render requirements only if any returned. if ($requirements && $output = install_display_requirements($install_state, $requirements)) { // Render requirements if any warnings or errors returned. if ($output = install_display_requirements($install_state, $requirements)) { return $output; } Loading Loading @@ -1692,11 +1692,12 @@ function install_download_additional_translations_operations(&$install_state) { $languages = \Drupal::languageManager()->getLanguages(); $operations = []; 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']) { // The installer language was already downloaded. Available translations are // stored in $install_state. 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 (!isset($install_state['translations'][$langcode])) { $operations[] = ['install_check_translations', [$langcode, $install_state['server_pattern']]]; } } Loading Loading @@ -1887,11 +1888,9 @@ function _install_module_batch($module, $module_name, &$context) { * @param string $server_pattern * Server access pattern (to replace language code, version number, etc. in). * * @return array|null * Requirements compliance array. If the translation was downloaded * successfully then an empty array is returned. Otherwise the requirements * error with detailed information. NULL if the file already exists for this * language code. * @return array * Requirements compliance array. If the translation cannot be downloaded this * will contain a requirements error with detailed information. */ function install_check_translations($langcode, $server_pattern) { $requirements = []; Loading Loading @@ -1920,11 +1919,6 @@ function install_check_translations($langcode, $server_pattern) { $translations_directory_exists = TRUE; } // The file already exists, no need to attempt to download. if ($existing_file = glob($translations_directory . '/drupal-*.' . $langcode . '.po')) { return; } $version = \Drupal::VERSION; // For dev releases, remove the '-dev' part and trust the translation server // to fall back to the latest stable release for that branch. Loading core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationExistingFileTest.php 0 → 100644 +72 −0 Original line number Diff line number Diff line <?php namespace Drupal\FunctionalTests\Installer; /** * Tests translation files for multiple languages get imported during install. * * @group Installer */ class InstallerTranslationExistingFileTest extends InstallerTestBase { /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * Overrides the language code in which to install Drupal. * * Choose one of the smaller languages on ftp.drupal.org. There is no way to * avoid using ftp.drupal.org since the code being tested runs extremely early * in the installer. However, even if the call to ftp.drupal.org fails then * this test will not fail as it will end up on the requirements page. * * @var string */ protected $langcode = 'xx-lolspeak'; /** * {@inheritdoc} */ protected function setUpLanguage() { // Place custom local translations in the translations directory. mkdir(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE); $po_contents = <<<ENDPO msgid "" msgstr "" ENDPO; // Create a misnamed translation file that // \Drupal\Core\StringTranslation\Translator\FileTranslation::findTranslationFiles() // will not find. file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0-DEV.xx-lolspeak.po', $po_contents); parent::setUpLanguage(); } /** * {@inheritdoc} */ protected function setUpProfile() { } /** * {@inheritdoc} */ protected function setUpSettings() { } /** * {@inheritdoc} */ protected function setUpSite() { } /** * Ensures language selection has not failed. */ public function testInstall() { // At this point we'll be on the profile selection or requirements screen. $this->assertSession()->statusCodeEquals(200); } } Loading
core/includes/install.core.inc +11 −17 Original line number Diff line number Diff line Loading @@ -1397,8 +1397,8 @@ function install_download_translation(&$install_state) { // Check whether all conditions are met to download. Download the translation // if possible. $requirements = install_check_translations($install_state['parameters']['langcode'], $install_state['server_pattern']); // Render requirements only if any returned. if ($requirements && $output = install_display_requirements($install_state, $requirements)) { // Render requirements if any warnings or errors returned. if ($output = install_display_requirements($install_state, $requirements)) { return $output; } Loading Loading @@ -1692,11 +1692,12 @@ function install_download_additional_translations_operations(&$install_state) { $languages = \Drupal::languageManager()->getLanguages(); $operations = []; 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']) { // The installer language was already downloaded. Available translations are // stored in $install_state. 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 (!isset($install_state['translations'][$langcode])) { $operations[] = ['install_check_translations', [$langcode, $install_state['server_pattern']]]; } } Loading Loading @@ -1887,11 +1888,9 @@ function _install_module_batch($module, $module_name, &$context) { * @param string $server_pattern * Server access pattern (to replace language code, version number, etc. in). * * @return array|null * Requirements compliance array. If the translation was downloaded * successfully then an empty array is returned. Otherwise the requirements * error with detailed information. NULL if the file already exists for this * language code. * @return array * Requirements compliance array. If the translation cannot be downloaded this * will contain a requirements error with detailed information. */ function install_check_translations($langcode, $server_pattern) { $requirements = []; Loading Loading @@ -1920,11 +1919,6 @@ function install_check_translations($langcode, $server_pattern) { $translations_directory_exists = TRUE; } // The file already exists, no need to attempt to download. if ($existing_file = glob($translations_directory . '/drupal-*.' . $langcode . '.po')) { return; } $version = \Drupal::VERSION; // For dev releases, remove the '-dev' part and trust the translation server // to fall back to the latest stable release for that branch. Loading
core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationExistingFileTest.php 0 → 100644 +72 −0 Original line number Diff line number Diff line <?php namespace Drupal\FunctionalTests\Installer; /** * Tests translation files for multiple languages get imported during install. * * @group Installer */ class InstallerTranslationExistingFileTest extends InstallerTestBase { /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * Overrides the language code in which to install Drupal. * * Choose one of the smaller languages on ftp.drupal.org. There is no way to * avoid using ftp.drupal.org since the code being tested runs extremely early * in the installer. However, even if the call to ftp.drupal.org fails then * this test will not fail as it will end up on the requirements page. * * @var string */ protected $langcode = 'xx-lolspeak'; /** * {@inheritdoc} */ protected function setUpLanguage() { // Place custom local translations in the translations directory. mkdir(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE); $po_contents = <<<ENDPO msgid "" msgstr "" ENDPO; // Create a misnamed translation file that // \Drupal\Core\StringTranslation\Translator\FileTranslation::findTranslationFiles() // will not find. file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0-DEV.xx-lolspeak.po', $po_contents); parent::setUpLanguage(); } /** * {@inheritdoc} */ protected function setUpProfile() { } /** * {@inheritdoc} */ protected function setUpSettings() { } /** * {@inheritdoc} */ protected function setUpSite() { } /** * Ensures language selection has not failed. */ public function testInstall() { // At this point we'll be on the profile selection or requirements screen. $this->assertSession()->statusCodeEquals(200); } }