title | issue |
---|---|
Specify Translation overwrites in write payloads |
NEXT-12900 |
- Changed
\Shopware\Core\Framework\DataAbstractionLayer\FieldSerializer\TranslatedFieldSerializer
to not overwrite values specified direct undertranslations
. - Changed
\Shopware\Core\Framework\DataAbstractionLayer\FieldSerializer\TranslationsAssociationFieldSerializer
so that translation values with iso-codes take precedence over values with language ids.
We specified the following rules for overwrites of translation values in write-payloads inside the DAL.
- Translations indexed by
iso-code
take precedence over values indexed bylanguage-id
- Translations specified on the
translations
-association take precedence over values specified directly on the translated field.
For a more information on those rules refer to the according ADR.
Let's take a look on some example payloads, to see what those rules mean.
Note: For all examples we assume that en-GB
is the system language.
Payload:
[
'name' => 'default',
'translations' => [
'name' => [
'en-GB' => 'en translation',
],
],
]
Result: en translation
, because values in translations
take precedence over those directly on the translated fields.
Payload:
[
'name' => 'default',
'translations' => [
'name' => [
Defaults::SYSTEM_LANGUAGE => 'en translation',
],
],
]
Result: en translation
, because of the same reasons as above.
Payload:
[
'name' => [
Defaults::SYSTEM_LANGUAGE => 'id translation',
'en-GB' => 'iso-code translation',
],
]
Result: iso-code translation
, because iso-code
take precedence over language-id
.
Payload:
[
'name' => 'default',
'translations' => [
'name' => [
Defaults::SYSTEM_LANGUAGE => 'id translation',
'en-GB' => 'iso-code translation',
],
],
]
Result: iso-code translation
, because iso-code
take precedence over language-id
.
Payload:
[
'name' => [
Defaults::SYSTEM_LANGUAGE => 'default',
],
'translations' => [
'name' => [
Defaults::SYSTEM_LANGUAGE => 'en translation',
],
],
]
Result: en translation
, because values in translations
take precedence over those directly on the translated fields.
Payload:
[
'name' => [
'en-GB' => 'default',
],
'translations' => [
'name' => [
Defaults::SYSTEM_LANGUAGE => 'en translation',
],
],
]
Result: default
, because iso-code
take precedence over language-id
, and that rule has a higher priority then the second "association rule".