Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3406cd3

Browse files
Skip target with state="needs-translation" in XLIFF files
1 parent 7848967 commit 3406cd3

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Symfony/Component/Translation/Loader/XliffFileLoader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ private function extractXliff1(\DOMDocument $dom, MessageCatalogue $catalogue, s
111111
continue;
112112
}
113113

114+
if (isset($translation->target) && 'needs-translation' === (string) $translation->target->attributes()['state']) {
115+
continue;
116+
}
117+
114118
$source = isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source;
115119
// If the xlf file has another encoding specified, try to convert it because
116120
// simple_xml will always return utf-8 encoded values

src/Symfony/Component/Translation/Tests/fixtures/resources.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
<target>with</target>
1919
<note>note</note>
2020
</trans-unit>
21+
<trans-unit id="5">
22+
<source>skipped</source>
23+
<target state="needs-translation">skipped</target>
24+
</trans-unit>
2125
</body>
2226
</file>
2327
</xliff>

src/Symfony/Component/Validator/Resources/translations/validators.zh_TW.xlf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,6 @@
430430
<source>The extension of the file is invalid ({{ extension }}). Allowed extensions are {{ extensions }}.</source>
431431
<target>無效的副檔名 ({{ extension }}). 允許的副檔名有 {{ extensions }}.</target>
432432
</trans-unit>
433-
<trans-unit id="111">
434-
<source>The detected character encoding is invalid ({{ detected }}). Allowed encodings are {{ encodings }}.</source>
435-
<target state="needs-review-translation">偵測到的字元編碼無效 ({{ detected }})。允許的編碼為 {{ encodings }}。</target>
436-
</trans-unit>
437-
<trans-unit id="112">
438-
<source>This is not a valid MAC address.</source>
439-
<target state="needs-review-translation">這不是一個有效的MAC地址。</target>
440-
</trans-unit>
441433
</body>
442434
</file>
443435
</xliff>

0 commit comments

Comments
 (0)