diff --git a/core/modules/locale/src/Form/TranslationStatusForm.php b/core/modules/locale/src/Form/TranslationStatusForm.php index 7539b8f..df43b62 100644 --- a/core/modules/locale/src/Form/TranslationStatusForm.php +++ b/core/modules/locale/src/Form/TranslationStatusForm.php @@ -277,8 +277,6 @@ public function validateForm(array &$form, FormStateInterface $form_state) { */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->moduleHandler->loadInclude('locale', 'fetch.inc'); - $this->moduleHandler->loadInclude('locale', 'bulk.inc'); - $langcodes = array_filter($form_state->getValue('langcodes')); $projects = array_filter($form_state->getValue('projects_update')); @@ -296,13 +294,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { batch_set($batch); } else { - // Set a batch to download and import translations. $batch = locale_translation_batch_fetch_build($projects, $langcodes, $options); batch_set($batch); - // Set a batch to update configuration as well. - if ($batch = locale_config_batch_update_components($options, $langcodes)) { - batch_set($batch); - } } } diff --git a/core/modules/locale/src/Tests/LocaleConfigTranslationImportTest.php b/core/modules/locale/src/Tests/LocaleConfigTranslationImportTest.php new file mode 100644 index 0000000..8ab1072 --- /dev/null +++ b/core/modules/locale/src/Tests/LocaleConfigTranslationImportTest.php @@ -0,0 +1,86 @@ +drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'administer permissions')); + $this->drupalLogin($admin_user); + + // Update module should not go out to d.o to check for updates. We override + // the url to the default update_test xml path. But without providing + // a mock xml file, no update data will be found. + \Drupal::config('update.settings')->set('fetch.url', url('update-test', array('absolute' => TRUE)))->save(); + + } + + /** + * Tests configuration translation import when locale module is enabled after + * a language was added. + */ + public function testConfigTranslationImport() { + + // Add a language. The Afrikaans translation file of locale_test_translate + // (test.af.po) has been prepared with a configuration translation. + \Drupal\language\Entity\ConfigurableLanguage::createFromLangcode('af')->save(); + + // Enable locale module. + $this->container->get('module_handler')->install(array('locale')); + $this->resetAll(); + + // Enable import of translations. By default this is disabled for automated + // tests. + \Drupal::config('locale.settings') + ->set('translation.import_enabled', TRUE) + ->save(); + + // Add translation permissions now the locale module has been enabled. + $edit = array( + 'authenticated[translate interface]' => 'translate interface', + ); + $this->drupalPostForm('admin/people/permissions', $edit, t('Save permissions')); + + // Check and update the translation status. This will import the African + // translations of locale_test_translate module. + $this->drupalGet('admin/reports/translations/check'); + + // Override the Drupal core translation status to be up to date. + // Drupal core should not be a subject in this test. + $status = locale_translation_get_status(); + $status['drupal']['af']->type = 'current'; + \Drupal::state()->set('locale.translation_status', $status); + + $this->drupalPostForm('admin/reports/translations', array(), t('Update translations')); + + // Check if configuration translations have been imported. + $override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'system.maintenance'); + $this->assertEqual($override->get('message'), 'Ons is tans besig met onderhoud op @site. Wees asseblief geduldig, ons sal binnekort weer terug wees.'); + } + +} diff --git a/core/modules/locale/tests/test.af.po b/core/modules/locale/tests/test.af.po new file mode 100644 index 0000000..2391464 --- /dev/null +++ b/core/modules/locale/tests/test.af.po @@ -0,0 +1,10 @@ +msgid "" +msgstr "" +"Project-Id-Version: Drupal 8\\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=UTF-8\\n" +"Content-Transfer-Encoding: 8bit\\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\\n" + +msgid "@site is currently under maintenance. We should be back shortly. Thank you for your patience." +msgstr "Ons is tans besig met onderhoud op @site. Wees asseblief geduldig, ons sal binnekort weer terug wees."