Skip to content

Commit 14dce9b

Browse files
Julian-Schuiererbmack
authored andcommitted
[BUGFIX] Process state attribute in correct tag in XLIFF 2.x files
The state attribute in XLIFF 2.x files must be on the <segment> tag, previously it was processed on the <target> tag. Resolves: #108032 Related: #107710 Releases: main Change-Id: Ib41bead734c03b872900d8cd6b6b9624cd03f6d8 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/91482 Tested-by: Chris Müller <typo3@brotkrueml.dev> Reviewed-by: Chris Müller <typo3@brotkrueml.dev> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Benni Mack <benni@typo3.org> Tested-by: core-ci <typo3@b13.com>
1 parent 4f2c52c commit 14dce9b

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

typo3/sysext/core/Classes/Localization/Loader/XliffLoader.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ private function parseXliff2(\SimpleXMLElement $root, MessageCatalogue $catalogu
230230
$translation = ($target !== false && isset($target[0])) ? (string)$target[0] : (string)$source[0];
231231
$catalogue->set($unitId, $translation, $domain);
232232
} else {
233-
// Check approval state (XLIFF 2.0 uses 'state' attribute on target)
233+
// Check approval state (XLIFF 2.0 uses 'state' attribute on segment)
234234
$approved = 'yes';
235-
if ($target !== false && isset($target[0])) {
236-
$state = (string)$target[0]['state'];
235+
if (isset($segment['state'])) {
236+
$state = (string)$segment['state'];
237237
// XLIFF 2.0 states: initial, translated, reviewed, final
238238
// We consider 'final' as approved, others depend on config
239239
if ($state === 'initial' || $state === 'translated') {
@@ -263,8 +263,8 @@ private function parseXliff2(\SimpleXMLElement $root, MessageCatalogue $catalogu
263263
$parsedTranslationElement[$formIndex] = $translation;
264264
} else {
265265
$approved = 'yes';
266-
if ($target !== false && isset($target[0])) {
267-
$state = (string)$target[0]['state'];
266+
if (isset($segment['state'])) {
267+
$state = (string)$segment['state'];
268268
if ($state === 'initial' || $state === 'translated') {
269269
$approved = 'no';
270270
}

typo3/sysext/core/Tests/Unit/Localization/Loader/Fixtures/de.locallang-v2.xlf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
</segment>
88
</unit>
99
<unit id="label2">
10-
<segment>
11-
<target state="final">Das ist Kennung Nummer 2 [approved]</target>
10+
<segment state="final">
11+
<target>Das ist Kennung Nummer 2 [approved]</target>
1212
</segment>
1313
</unit>
1414
<unit id="label3">
15-
<segment>
16-
<target state="translated">Das ist Kennung Nummer 3 [not approved]</target>
15+
<segment state="translated">
16+
<target>Das ist Kennung Nummer 3 [not approved]</target>
1717
</segment>
1818
</unit>
1919
</file>

typo3/sysext/core/Tests/Unit/Localization/Loader/Fixtures/fr.locallang-v2.xlf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
</segment>
99
</unit>
1010
<unit id="label2">
11-
<segment>
11+
<segment state="final">
1212
<source>This is label #2</source>
13-
<target state="final">Ceci est le libellé no. 2 [approved]</target>
13+
<target>Ceci est le libellé no. 2 [approved]</target>
1414
</segment>
1515
</unit>
1616
<unit id="label3">
17-
<segment>
17+
<segment state="translated">
1818
<source>This is label #3</source>
19-
<target state="translated">Ceci est le libellé no. 3 [not approved]</target>
19+
<target>Ceci est le libellé no. 3 [not approved]</target>
2020
</segment>
2121
</unit>
2222
</file>

0 commit comments

Comments
 (0)