diff --git a/core/modules/config_translation/src/FormElement/PluralVariants.php b/core/modules/config_translation/src/FormElement/PluralVariants.php
index ec6b977..e13e628 100644
--- a/core/modules/config_translation/src/FormElement/PluralVariants.php
+++ b/core/modules/config_translation/src/FormElement/PluralVariants.php
@@ -25,21 +25,27 @@ protected function getSourceElement(LanguageInterface $source_language, $source_
$values = explode(LOCALE_PLURAL_DELIMITER, $source_config);
$element = array(
'#type' => 'fieldset',
- '#title' => SafeMarkup::format('@label (@source_language)', array(
- '@label' => $this->t($this->definition->getLabel()),
- '@source_language' => $source_language->getName(),
- )),
+ '#title' => $this->t($this->definition->getLabel()),
'#tree' => TRUE,
);
+ $element['source_language'] = array(
+ '#type' => 'inline_template',
+ '#template' => '{{ source_language }}',
+ '#context' => array(
+ 'source_language' => $this->t('Source string (@language)', array('@language' => $source_language->getName())),
+ ),
+ );
for ($i = 0; $i < $plurals; $i++) {
$element[$i] = array(
- '#type' => 'item',
- // @todo Should use better labels https://www.drupal.org/node/2499639
- '#title' => $i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form'),
- '#markup' => SafeMarkup::format('@value', array(
- '@langcode' => $source_language->getId(),
- '@value' => isset($values[$i]) ? $values[$i] : $this->t('(Empty)'),
- )),
+ '#type' => 'inline_template',
+ '#template' => '
{{ value }}
',
+ '#context' => array(
+ 'id' => 'edit-source-config-format-plural-string-' . $i,
+ // @todo Should use better labels https://www.drupal.org/node/2499639
+ 'label' => $i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form'),
+ 'langcode' => $source_language->getId(),
+ 'value' => isset($values[$i]) ? $values[$i] : $this->t('(Empty)'),
+ ),
);
}
return $element;
@@ -53,12 +59,16 @@ protected function getTranslationElement(LanguageInterface $translation_language
$values = explode(LOCALE_PLURAL_DELIMITER, $translation_config);
$element = array(
'#type' => 'fieldset',
- '#title' => SafeMarkup::format('@label (@translation_language)', array(
- '@label' => $this->t($this->definition->getLabel()),
- '@translation_language' => $translation_language->getName(),
- )),
+ '#title' => $this->t($this->definition->getLabel()),
'#tree' => TRUE,
);
+ $element['translation_language'] = array(
+ '#type' => 'inline_template',
+ '#template' => '{{ translation_language }}',
+ '#context' => array(
+ 'translation_language' => $this->t('Translated string (@language)', array('@language' => $translation_language->getName())),
+ ),
+ );
for ($i = 0; $i < $plurals; $i++) {
$element[$i] = array(
'#type' => 'textfield',
diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php
index 13890c0..811a5f0 100644
--- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php
+++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php
@@ -665,10 +665,10 @@ public function testPluralConfigStringsSourceElements() {
// Check if the expected number of source elements are present.
foreach ($data['expected'] as $index => $expected) {
if ($expected) {
- $this->assertRaw('edit-source-config-names-viewsviewfiles-display-default-display-options-fields-count-format-plural-string-' . $index);
+ $this->assertRaw('edit-source-config-format-plural-string-' . $index);
}
else {
- $this->assertNoRaw('edit-source-config-names-viewsviewfiles-display-default-display-options-fields-count-format-plural-string-' . $index);
+ $this->assertNoRaw('edit-source-config-format-plural-string-' . $index);
}
}
}
diff --git a/core/modules/locale/src/Form/TranslateEditForm.php b/core/modules/locale/src/Form/TranslateEditForm.php
index dbd450a..8a437f0 100644
--- a/core/modules/locale/src/Form/TranslateEditForm.php
+++ b/core/modules/locale/src/Form/TranslateEditForm.php
@@ -69,35 +69,27 @@ public function buildForm(array $form, FormStateInterface $form_state) {
// Add original string value and mark as non-plural.
$plural = FALSE;
$form['strings'][$string->lid]['original'] = array(
- '#type' => 'item',
- '#title' => $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))),
- '#title_display' => 'invisible',
- '#plain_text' => $source_array[0],
- '#preffix' => '',
- '#suffix' => '',
+ '#type' => 'inline_template',
+ '#template' => '{{ source_language }}{{ source_value }}',
+ '#context' => array(
+ 'source_language' => $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))),
+ 'source_value' => $source_array[0],
+ ),
);
}
else {
// Add original string value and mark as plural.
$plural = TRUE;
- $original_singular = [
- '#type' => 'item',
- '#title' => $this->t('Singular form'),
- '#plain_text' => $source_array[0],
- '#prefix' => '' . $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))) . '',
- '#suffix' => '',
- ];
- $original_plural = [
- '#type' => 'item',
- '#title' => $this->t('Plural form'),
- '#plain_text' => $source_array[1],
- '#preffix' => '',
- '#suffix' => '',
- ];
$form['strings'][$string->lid]['original'] = [
- $original_singular,
- ['#markup' => '
'],
- $original_plural,
+ '#type' => 'inline_template',
+ '#template' => '{{ source_language }}{{ original_singular }}
{{ original_plural }}
',
+ '#context' => array(
+ 'source_language' => $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))),
+ 'singular_label' => $this->t('Singular form'),
+ 'plural_label' => $this->t('Plural form'),
+ 'original_singular' => $source_array[0],
+ 'original_plural' => $source_array[1],
+ ),
];
}
if (!empty($string->context)) {
@@ -110,13 +102,20 @@ public function buildForm(array $form, FormStateInterface $form_state) {
],
];
}
+
+ $form['strings'][$string->lid]['translations'] = array(
+ '#type' => 'inline_template',
+ '#template' => '{{ translation_language }}',
+ '#context' => array(
+ 'translation_language' => $this->t('Translated string (@language)', array('@language' => $langname)),
+ ),
+ );
+
// Approximate the number of rows to use in the default textarea.
$rows = min(ceil(str_word_count($source_array[0]) / 12), 10);
if (!$plural) {
$form['strings'][$string->lid]['translations'][0] = array(
'#type' => 'textarea',
- '#title' => $this->t('Translated string (@language)', array('@language' => $langname)),
- '#title_display' => 'invisible',
'#rows' => $rows,
'#default_value' => $translation_array[0],
'#attributes' => array('lang' => $langcode),
@@ -132,7 +131,6 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#rows' => $rows,
'#default_value' => isset($translation_array[$i]) ? $translation_array[$i] : '',
'#attributes' => array('lang' => $langcode),
- '#prefix' => $i == 0 ? ('' . $this->t('Translated string (@language)', array('@language' => $langname)) . '') : '',
);
}
if ($plurals == 2) {