Skip to content
Snippets Groups Projects
Commit 3c88f61f authored by Alex Pott's avatar Alex Pott
Browse files

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

(cherry picked from commit d466fb2c)
parent 8c1d6354
No related branches found
No related tags found
No related merge requests found
......@@ -101,7 +101,8 @@ protected function getSourceElement(LanguageInterface $source_language, $source_
return array(
'#type' => 'item',
'#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(),
)),
'#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 <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(),
)),
'#default_value' => $translation_config,
......
......@@ -26,6 +26,7 @@ protected function getSourceElement(LanguageInterface $source_language, $source_
$element = array(
'#type' => 'fieldset',
'#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()),
'@source_language' => $source_language->getName(),
)),
......@@ -54,6 +55,7 @@ protected function getTranslationElement(LanguageInterface $translation_language
$element = array(
'#type' => 'fieldset',
'#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()),
'@translation_language' => $translation_language->getName(),
)),
......
......@@ -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);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment