diff --git a/core/modules/config_translation/src/FormElement/FormElementBase.php b/core/modules/config_translation/src/FormElement/FormElementBase.php index 746ae1d..4418361 100644 --- a/core/modules/config_translation/src/FormElement/FormElementBase.php +++ b/core/modules/config_translation/src/FormElement/FormElementBase.php @@ -101,7 +101,8 @@ protected function getSourceElement(LanguageInterface $source_language, $source_ return array( '#type' => 'item', '#title' => $this->t('@label (@source_language)', array( - '@label' => $this->definition->getLabel(), + // Labels originate from configuration schema and are translatable. + '@label' => $this->t($this->definition->getLabel()), '@source_language' => $source_language->getName(), )), '#markup' => $value, @@ -163,7 +164,8 @@ protected function getTranslationElement(LanguageInterface $translation_language // Add basic properties that apply to all form elements. return array( '#title' => $this->t('@label (@source_language)', array( - '@label' => $this->definition['label'], + // Labels originate from configuration schema and are translatable. + '@label' => $this->t($this->definition->getLabel()), '@source_language' => $translation_language->getName(), )), '#default_value' => $translation_config, diff --git a/core/modules/config_translation/src/FormElement/PluralVariants.php b/core/modules/config_translation/src/FormElement/PluralVariants.php index ec6b977..2b3ec3b 100644 --- a/core/modules/config_translation/src/FormElement/PluralVariants.php +++ b/core/modules/config_translation/src/FormElement/PluralVariants.php @@ -26,6 +26,7 @@ protected function getSourceElement(LanguageInterface $source_language, $source_ $element = array( '#type' => 'fieldset', '#title' => SafeMarkup::format('@label (@source_language)', array( + // Labels originate from configuration schema and are translatable. '@label' => $this->t($this->definition->getLabel()), '@source_language' => $source_language->getName(), )), @@ -54,6 +55,7 @@ protected function getTranslationElement(LanguageInterface $translation_language $element = array( '#type' => 'fieldset', '#title' => SafeMarkup::format('@label (@translation_language)', array( + // Labels originate from configuration schema and are translatable. '@label' => $this->t($this->definition->getLabel()), '@translation_language' => $translation_language->getName(), )), diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php index cb7e0d1..f2c3c7c 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php @@ -128,10 +128,12 @@ protected function setUp() { public function testSiteInformationTranslationUi() { $this->drupalLogin($this->adminUser); - $site_name = 'Site name for testing configuration translation'; + $site_name = 'Name of the site for testing configuration translation'; $site_slogan = 'Site slogan for testing configuration translation'; + $site_name_label = 'Site name'; $fr_site_name = 'Nom du site pour tester la configuration traduction'; $fr_site_slogan = 'Slogan du site pour tester la traduction de configuration'; + $fr_site_name_label = 'Libellé du champ "Nom du site"'; $translation_base_url = 'admin/config/system/site-information/translate'; // Set site name and slogan for default language. @@ -189,6 +191,37 @@ public function testSiteInformationTranslationUi() { $this->drupalGet("fr/$translation_base_url/fr/edit"); $this->assertText($site_name); $this->assertText($site_slogan); + + // Translate 'Site name' label in French. + $search = array( + 'string' => $site_name_label, + 'langcode' => 'fr', + 'translation' => 'untranslated', + ); + $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter')); + + $textarea = current($this->xpath('//textarea')); + $lid = (string) $textarea[0]['name']; + $edit = array( + $lid => $fr_site_name_label, + ); + $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations')); + + // Ensure that the label is in French (and not in English). + $this->drupalGet("fr/$translation_base_url/fr/edit"); + $this->assertText($fr_site_name_label); + $this->assertNoText($site_name_label); + + // Ensure that the label is also in French (and not in English) + // when editing another language with the interface in French. + $this->drupalGet("fr/$translation_base_url/ta/edit"); + $this->assertText($fr_site_name_label); + $this->assertNoText($site_name_label); + + // Ensure that the label is not translated when the interface is in English. + $this->drupalGet("$translation_base_url/fr/edit"); + $this->assertText($site_name_label); + $this->assertNoText($fr_site_name_label); } /**