Loading core/modules/locale/src/LocaleConfigSubscriber.php +2 −2 Original line number Diff line number Diff line Loading @@ -148,8 +148,8 @@ protected function processTranslatableData($name, array $config, array $translat continue; } if (is_array($item)) { $reference_config = isset($reference_config[$key]) ? $reference_config[$key] : []; $this->processTranslatableData($name, $config[$key], $item, $langcode, $reference_config); $reference_config_item = isset($reference_config[$key]) ? $reference_config[$key] : []; $this->processTranslatableData($name, $config[$key], $item, $langcode, $reference_config_item); } else { $this->saveCustomizedTranslation($name, $item->getUntranslatedString(), $item->getOption('context'), $config[$key], $langcode); Loading core/modules/locale/tests/modules/locale_test/config/install/locale_test.translation_multiple.yml 0 → 100644 +8 −0 Original line number Diff line number Diff line test: English test test_multiple: string: 'A string' another_string: 'Another string' test_after_multiple: false test_after_multiple: string: 'After a string' another_string: 'After another string' core/modules/locale/tests/modules/locale_test/config/schema/locale_test.schema.yml +37 −0 Original line number Diff line number Diff line Loading @@ -19,3 +19,40 @@ locale_test.translation: label: 'Test' # See \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest translatable: true locale_test.translation_multiple: type: config_object label: 'translation settings' mapping: test: type: string label: 'Test' # See \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest translatable: true test_multiple: type: mapping label: 'Multiple settings' mapping: string: type: string label: 'A string' translatable: true another_string: type: string label: 'Another string' translatable: true test_after_multiple: type: boolean label: 'Test after multiple' test_after_multiple: type: mapping label: 'Test after multiple settings' mapping: string: type: string label: 'A string' translatable: true another_string: type: string label: 'Another string' translatable: true core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php +20 −2 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ protected function setUpLocale() { // Set up the locale database the same way we have in the config samples. $this->setUpNoTranslation('locale_test.no_translation', 'test', 'Test', 'de'); $this->setUpTranslation('locale_test.translation', 'test', 'English test', 'German test', 'de'); $this->setUpTranslation('locale_test.translation_multiple', 'test', 'English test', 'German test', 'de'); } /** Loading @@ -111,6 +112,23 @@ public function testCreateTranslation() { $this->assertTranslation($config_name, 'Test (German)', 'de'); } /** * Tests creating translations configuration with multi value settings. */ public function testCreateTranslationMultiValue() { $config_name = 'locale_test.translation_multiple'; $this->saveLanguageOverride($config_name, 'test_multiple', ['string' => 'String (German)', 'another_string' => 'Another string (German)'], 'de'); $this->saveLanguageOverride($config_name, 'test_after_multiple', ['string' => 'After string (German)', 'another_string' => 'After another string (German)'], 'de'); $strings = $this->stringStorage->getTranslations([ 'type' => 'configuration', 'name' => $config_name, 'language' => 'de', 'translated' => TRUE, ]); $this->assertCount(5, $strings); } /** * Tests importing community translations of shipped configuration. */ Loading Loading @@ -245,7 +263,7 @@ protected function setUpTranslation($config_name, $key, $source, $translation, $ * The configuration name. * @param string $key * The configuration key. * @param string $value * @param string|array $value * The configuration value to save. * @param string $langcode * The language code. Loading Loading @@ -446,7 +464,7 @@ protected function assertNoTranslation($config_name, $langcode) { * * @param string $config_name * The configuration name. * @param string $translation * @param string|array $translation * The translation. * @param string $langcode * The language code. Loading Loading
core/modules/locale/src/LocaleConfigSubscriber.php +2 −2 Original line number Diff line number Diff line Loading @@ -148,8 +148,8 @@ protected function processTranslatableData($name, array $config, array $translat continue; } if (is_array($item)) { $reference_config = isset($reference_config[$key]) ? $reference_config[$key] : []; $this->processTranslatableData($name, $config[$key], $item, $langcode, $reference_config); $reference_config_item = isset($reference_config[$key]) ? $reference_config[$key] : []; $this->processTranslatableData($name, $config[$key], $item, $langcode, $reference_config_item); } else { $this->saveCustomizedTranslation($name, $item->getUntranslatedString(), $item->getOption('context'), $config[$key], $langcode); Loading
core/modules/locale/tests/modules/locale_test/config/install/locale_test.translation_multiple.yml 0 → 100644 +8 −0 Original line number Diff line number Diff line test: English test test_multiple: string: 'A string' another_string: 'Another string' test_after_multiple: false test_after_multiple: string: 'After a string' another_string: 'After another string'
core/modules/locale/tests/modules/locale_test/config/schema/locale_test.schema.yml +37 −0 Original line number Diff line number Diff line Loading @@ -19,3 +19,40 @@ locale_test.translation: label: 'Test' # See \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest translatable: true locale_test.translation_multiple: type: config_object label: 'translation settings' mapping: test: type: string label: 'Test' # See \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest translatable: true test_multiple: type: mapping label: 'Multiple settings' mapping: string: type: string label: 'A string' translatable: true another_string: type: string label: 'Another string' translatable: true test_after_multiple: type: boolean label: 'Test after multiple' test_after_multiple: type: mapping label: 'Test after multiple settings' mapping: string: type: string label: 'A string' translatable: true another_string: type: string label: 'Another string' translatable: true
core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php +20 −2 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ protected function setUpLocale() { // Set up the locale database the same way we have in the config samples. $this->setUpNoTranslation('locale_test.no_translation', 'test', 'Test', 'de'); $this->setUpTranslation('locale_test.translation', 'test', 'English test', 'German test', 'de'); $this->setUpTranslation('locale_test.translation_multiple', 'test', 'English test', 'German test', 'de'); } /** Loading @@ -111,6 +112,23 @@ public function testCreateTranslation() { $this->assertTranslation($config_name, 'Test (German)', 'de'); } /** * Tests creating translations configuration with multi value settings. */ public function testCreateTranslationMultiValue() { $config_name = 'locale_test.translation_multiple'; $this->saveLanguageOverride($config_name, 'test_multiple', ['string' => 'String (German)', 'another_string' => 'Another string (German)'], 'de'); $this->saveLanguageOverride($config_name, 'test_after_multiple', ['string' => 'After string (German)', 'another_string' => 'After another string (German)'], 'de'); $strings = $this->stringStorage->getTranslations([ 'type' => 'configuration', 'name' => $config_name, 'language' => 'de', 'translated' => TRUE, ]); $this->assertCount(5, $strings); } /** * Tests importing community translations of shipped configuration. */ Loading Loading @@ -245,7 +263,7 @@ protected function setUpTranslation($config_name, $key, $source, $translation, $ * The configuration name. * @param string $key * The configuration key. * @param string $value * @param string|array $value * The configuration value to save. * @param string $langcode * The language code. Loading Loading @@ -446,7 +464,7 @@ protected function assertNoTranslation($config_name, $langcode) { * * @param string $config_name * The configuration name. * @param string $translation * @param string|array $translation * The translation. * @param string $langcode * The language code. Loading