diff --git a/core/modules/locale/src/Form/ImportForm.php b/core/modules/locale/src/Form/ImportForm.php index ae4424c88c818a3a0f52d092095b15c69c4e9bb7..e3448b303cee12d344ab3e5da53d1fec908aa698 100644 --- a/core/modules/locale/src/Form/ImportForm.php +++ b/core/modules/locale/src/Form/ImportForm.php @@ -171,6 +171,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { + \Drupal::moduleHandler()->loadInclude('locale', 'translation.inc'); // Add language, if not yet supported. $language = $this->languageManager->getLanguage($form_state->getValue('langcode')); if (empty($language)) { @@ -178,16 +179,22 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $language->save(); drupal_set_message($this->t('The language %language has been created.', array('%language' => $this->t($language->label())))); } - $options = array( + $options = array_merge(_locale_translation_default_update_options(), array( 'langcode' => $form_state->getValue('langcode'), 'overwrite_options' => $form_state->getValue('overwrite_options'), 'customized' => $form_state->getValue('customized') ? LOCALE_CUSTOMIZED : LOCALE_NOT_CUSTOMIZED, - ); + )); $this->moduleHandler->loadInclude('locale', 'bulk.inc'); $file = locale_translate_file_attach_properties($this->file, $options); $batch = locale_translate_batch_build(array($file->uri => $file), $options); batch_set($batch); + // Create or update all configuration translations for this language. + \Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc'); + if ($batch = locale_config_batch_update_components($options, array($form_state->getValue('langcode')))) { + batch_set($batch); + } + $form_state->setRedirect('locale.translate_page'); } } diff --git a/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php index e0b93fe691ae35fbaba3b65c8f9158f6f3a53896..7dc4baf27a9b3700d11acb56f9144c53bf19111a 100644 --- a/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php +++ b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php @@ -335,6 +335,22 @@ public function testConfigPoFile() { } } + /** + * Tests .po file import with user.settings configuration. + */ + public function testConfigtranslationImportingPoFile() { + // Set the language code. + $langcode = 'de'; + + // Import a .po file to translate. + $this->importPoFile($this->getPoFileWithConfigDe(), array( + 'langcode' => $langcode)); + + // Check that the 'Anonymous' string is translated. + $config = \Drupal::languageManager()->getLanguageConfigOverride($langcode, 'user.settings'); + $this->assertEqual($config->get('anonymous'), 'Anonymous German'); + } + /** * Helper function: import a standalone .po file in a given language. * @@ -592,4 +608,22 @@ public function getPoFileWithConfig() { EOF; } + /** + * Helper function that returns a .po file with configuration translations. + */ + public function getPoFileWithConfigDe() { + return <<< EOF +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 "Anonymous" +msgstr "Anonymous German" + +EOF; + } }