Commit d466fb2c authored by alexpott's avatar alexpott

Issue #2697291 by maxocub, Gábor Hojtsy, alexpott: Config translation form...

Issue #2697291 by maxocub, Gábor Hojtsy, alexpott: Config translation form labels are not translated
parent 187a3c54
...@@ -101,7 +101,8 @@ protected function getSourceElement(LanguageInterface $source_language, $source_ ...@@ -101,7 +101,8 @@ protected function getSourceElement(LanguageInterface $source_language, $source_
return array( return array(
'#type' => 'item', '#type' => 'item',
'#title' => $this->t('@label <span class="visually-hidden">(@source_language)</span>', array( '#title' => $this->t('@label <span class="visually-hidden">(@source_language)</span>', array(
'@label' => $this->definition->getLabel(), // Labels originate from configuration schema and are translatable.
'@label' => $this->t($this->definition->getLabel()),
'@source_language' => $source_language->getName(), '@source_language' => $source_language->getName(),
)), )),
'#markup' => $value, '#markup' => $value,
...@@ -163,7 +164,8 @@ protected function getTranslationElement(LanguageInterface $translation_language ...@@ -163,7 +164,8 @@ protected function getTranslationElement(LanguageInterface $translation_language
// Add basic properties that apply to all form elements. // Add basic properties that apply to all form elements.
return array( return array(
'#title' => $this->t('@label <span class="visually-hidden">(@source_language)</span>', array( '#title' => $this->t('@label <span class="visually-hidden">(@source_language)</span>', array(
'@label' => $this->definition['label'], // Labels originate from configuration schema and are translatable.
'@label' => $this->t($this->definition->getLabel()),
'@source_language' => $translation_language->getName(), '@source_language' => $translation_language->getName(),
)), )),
'#default_value' => $translation_config, '#default_value' => $translation_config,
......
...@@ -26,6 +26,7 @@ protected function getSourceElement(LanguageInterface $source_language, $source_ ...@@ -26,6 +26,7 @@ protected function getSourceElement(LanguageInterface $source_language, $source_
$element = array( $element = array(
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => SafeMarkup::format('@label <span class="visually-hidden">(@source_language)</span>', array( '#title' => SafeMarkup::format('@label <span class="visually-hidden">(@source_language)</span>', array(
// Labels originate from configuration schema and are translatable.
'@label' => $this->t($this->definition->getLabel()), '@label' => $this->t($this->definition->getLabel()),
'@source_language' => $source_language->getName(), '@source_language' => $source_language->getName(),
)), )),
...@@ -54,6 +55,7 @@ protected function getTranslationElement(LanguageInterface $translation_language ...@@ -54,6 +55,7 @@ protected function getTranslationElement(LanguageInterface $translation_language
$element = array( $element = array(
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => SafeMarkup::format('@label <span class="visually-hidden">(@translation_language)</span>', array( '#title' => SafeMarkup::format('@label <span class="visually-hidden">(@translation_language)</span>', array(
// Labels originate from configuration schema and are translatable.
'@label' => $this->t($this->definition->getLabel()), '@label' => $this->t($this->definition->getLabel()),
'@translation_language' => $translation_language->getName(), '@translation_language' => $translation_language->getName(),
)), )),
......
...@@ -128,10 +128,12 @@ protected function setUp() { ...@@ -128,10 +128,12 @@ protected function setUp() {
public function testSiteInformationTranslationUi() { public function testSiteInformationTranslationUi() {
$this->drupalLogin($this->adminUser); $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_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_name = 'Nom du site pour tester la configuration traduction';
$fr_site_slogan = 'Slogan du site pour tester la traduction de configuration'; $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'; $translation_base_url = 'admin/config/system/site-information/translate';
// Set site name and slogan for default language. // Set site name and slogan for default language.
...@@ -189,6 +191,37 @@ public function testSiteInformationTranslationUi() { ...@@ -189,6 +191,37 @@ public function testSiteInformationTranslationUi() {
$this->drupalGet("fr/$translation_base_url/fr/edit"); $this->drupalGet("fr/$translation_base_url/fr/edit");
$this->assertText($site_name); $this->assertText($site_name);
$this->assertText($site_slogan); $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);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment