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..2d2b6b4 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php @@ -132,6 +132,7 @@ public function testSiteInformationTranslationUi() { $site_slogan = 'Site slogan for testing configuration translation'; $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 +190,26 @@ 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', + '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 translated in French + $this->drupalGet("fr/$translation_base_url/fr/edit"); + $this->assertText($fr_site_name_label, "The label '$fr_site_name_label' was not found"); } /**