diff --git a/core/modules/config_translation/src/FormElement/ListElement.php b/core/modules/config_translation/src/FormElement/ListElement.php index 8bd8a52..9365fc2 100644 --- a/core/modules/config_translation/src/FormElement/ListElement.php +++ b/core/modules/config_translation/src/FormElement/ListElement.php @@ -54,8 +54,7 @@ public function getTranslationBuild(LanguageInterface $source_language, Language $build = array(); foreach ($this->element as $key => $element) { $sub_build = array(); - // Make the specific element key, "$base_key.$key". - $element_key = implode('.', array_filter(array($base_key, $key))); + $element_key = isset($base_key) ? "$base_key.$key" : $key; $definition = $element->getDataDefinition(); if ($form_element = ConfigTranslationFormBase::createFormElement($element)) { @@ -88,7 +87,7 @@ public function getTranslationBuild(LanguageInterface $source_language, Language */ public function setConfig(Config $base_config, LanguageConfigOverride $config_translation, $config_values, $base_key = NULL) { foreach ($this->element as $key => $element) { - $element_key = implode('.', array_filter(array($base_key, $key))); + $element_key = isset($base_key) ? "$base_key.$key" : $key; if ($form_element = ConfigTranslationFormBase::createFormElement($element)) { // Traverse into the next level of the configuration. $value = isset($config_values[$key]) ? $config_values[$key] : NULL; diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php index 8671c3c..ae0d250 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php @@ -703,6 +703,46 @@ public function testAlterInfo() { } /** + * Tests the sequence data type translation. + */ + public function testSequenceTranslation() { + $this->drupalLogin($this->adminUser); + /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */ + $config_factory = $this->container->get('config.factory'); + + $expected = array( + 'kitten', + 'llama', + 'elephant' + ); + $actual = $config_factory + ->getEditable('config_translation_test.content') + ->get('animals'); + $this->assertEqual($expected, $actual); + + $edit = array( + 'translation[config_names][config_translation_test.content][content][value]' => '

Hello World - FR

', + 'translation[config_names][config_translation_test.content][animals][0]' => 'kitten - FR', + 'translation[config_names][config_translation_test.content][animals][1]' => 'llama - FR', + 'translation[config_names][config_translation_test.content][animals][2]' => 'elephant - FR', + ); + $this->drupalPostForm('admin/config/media/file-system/translate/fr/add', $edit, t('Save translation')); + + $this->container->get('language.config_factory_override') + ->setLanguage(new Language(array('id' => 'fr'))); + + $expected = array( + 'kitten - FR', + 'llama - FR', + 'elephant - FR', + ); + $actual = $config_factory + ->get('config_translation_test.content') + ->get('animals'); + $this->assertEqual($expected, $actual); + } + + /** * Test text_format translation. */ public function testTextFormatTranslation() { diff --git a/core/modules/config_translation/tests/modules/config_translation_test/config/install/config_translation_test.content.yml b/core/modules/config_translation/tests/modules/config_translation_test/config/install/config_translation_test.content.yml index 5a4d4bb..307db48 100644 --- a/core/modules/config_translation/tests/modules/config_translation_test/config/install/config_translation_test.content.yml +++ b/core/modules/config_translation/tests/modules/config_translation_test/config/install/config_translation_test.content.yml @@ -4,3 +4,7 @@ langcode: en content: value: "

Hello World

" format: plain_text +animals: + - kitten + - llama + - elephant diff --git a/core/modules/config_translation/tests/modules/config_translation_test/config/schema/config_translation_test.schema.yml b/core/modules/config_translation/tests/modules/config_translation_test/config/schema/config_translation_test.schema.yml index 757448f..4e43d5f 100644 --- a/core/modules/config_translation/tests/modules/config_translation_test/config/schema/config_translation_test.schema.yml +++ b/core/modules/config_translation/tests/modules/config_translation_test/config/schema/config_translation_test.schema.yml @@ -16,3 +16,9 @@ config_translation_test.content: content: type: text_format label: 'Content' + animals: + type: sequence + label: 'Animals' + sequence: + - type: label +