Unverified Commit ea0ab7e5 authored by alexpott's avatar alexpott

Issue #2939356 by Lendude, mediabounds, Manuel Garcia, validoll, justclint,...

Issue #2939356 by Lendude, mediabounds, Manuel Garcia, validoll, justclint, hctom: Fatal error during import translaton of workflows.workflow.editorial.yml config
parent d9519bae
...@@ -148,8 +148,8 @@ protected function processTranslatableData($name, array $config, array $translat ...@@ -148,8 +148,8 @@ protected function processTranslatableData($name, array $config, array $translat
continue; continue;
} }
if (is_array($item)) { if (is_array($item)) {
$reference_config = isset($reference_config[$key]) ? $reference_config[$key] : []; $reference_config_item = isset($reference_config[$key]) ? $reference_config[$key] : [];
$this->processTranslatableData($name, $config[$key], $item, $langcode, $reference_config); $this->processTranslatableData($name, $config[$key], $item, $langcode, $reference_config_item);
} }
else { else {
$this->saveCustomizedTranslation($name, $item->getUntranslatedString(), $item->getOption('context'), $config[$key], $langcode); $this->saveCustomizedTranslation($name, $item->getUntranslatedString(), $item->getOption('context'), $config[$key], $langcode);
......
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'
...@@ -19,3 +19,40 @@ locale_test.translation: ...@@ -19,3 +19,40 @@ locale_test.translation:
label: 'Test' label: 'Test'
# See \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest # See \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest
translatable: true 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
...@@ -99,6 +99,7 @@ protected function setUpLocale() { ...@@ -99,6 +99,7 @@ protected function setUpLocale() {
// Set up the locale database the same way we have in the config samples. // Set up the locale database the same way we have in the config samples.
$this->setUpNoTranslation('locale_test.no_translation', 'test', 'Test', 'de'); $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', 'test', 'English test', 'German test', 'de');
$this->setUpTranslation('locale_test.translation_multiple', 'test', 'English test', 'German test', 'de');
} }
/** /**
...@@ -111,6 +112,23 @@ public function testCreateTranslation() { ...@@ -111,6 +112,23 @@ public function testCreateTranslation() {
$this->assertTranslation($config_name, 'Test (German)', 'de'); $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. * Tests importing community translations of shipped configuration.
*/ */
...@@ -245,7 +263,7 @@ protected function setUpTranslation($config_name, $key, $source, $translation, $ ...@@ -245,7 +263,7 @@ protected function setUpTranslation($config_name, $key, $source, $translation, $
* The configuration name. * The configuration name.
* @param string $key * @param string $key
* The configuration key. * The configuration key.
* @param string $value * @param string|array $value
* The configuration value to save. * The configuration value to save.
* @param string $langcode * @param string $langcode
* The language code. * The language code.
...@@ -446,7 +464,7 @@ protected function assertNoTranslation($config_name, $langcode) { ...@@ -446,7 +464,7 @@ protected function assertNoTranslation($config_name, $langcode) {
* *
* @param string $config_name * @param string $config_name
* The configuration name. * The configuration name.
* @param string $translation * @param string|array $translation
* The translation. * The translation.
* @param string $langcode * @param string $langcode
* The language code. * The language code.
......
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