fix(compiler): i18n - ignore alt-trans
tags in XLIFF 1.2 (#33450)
The parser was accidentally reading the `target` tag below the `alt-trans` target and overriding the correct `target` tag. (This already worked in `$localize` but a test has been added to confirm.) Fixes #33161 PR Close #33450
This commit is contained in:

committed by
Andrew Kushnir

parent
a3034ef92e
commit
936700ad9f
@ -373,6 +373,34 @@ describe('Xliff1TranslationParser', () => {
|
||||
.toEqual(ɵmakeParsedTranslation(['Translated first sentence.']));
|
||||
});
|
||||
|
||||
it('should ignore alt-trans targets', () => {
|
||||
const XLIFF = `
|
||||
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<file source-language="en" target-language="fr" datatype="plaintext" original="ng2.template">
|
||||
<body>
|
||||
<trans-unit datatype="html" approved="no" id="registration.submit">
|
||||
<source>Continue</source>
|
||||
<target state="translated" xml:lang="de">Weiter</target>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/auth/registration-form/registration-form.component.html</context>
|
||||
<context context-type="linenumber">69</context>
|
||||
</context-group>
|
||||
<?sid 1110954287-0?>
|
||||
<alt-trans origin="autoFuzzy" tool="Swordfish" match-quality="71" ts="63">
|
||||
<source xml:lang="en">Content</source>
|
||||
<target state="translated" xml:lang="de">Content</target>
|
||||
</alt-trans>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>`;
|
||||
|
||||
const parser = new Xliff1TranslationParser();
|
||||
const result = parser.parse('/some/file.xlf', XLIFF);
|
||||
expect(result.translations['registration.submit'])
|
||||
.toEqual(ɵmakeParsedTranslation(['Weiter']));
|
||||
});
|
||||
|
||||
describe('[structure errors]', () => {
|
||||
it('should throw when a trans-unit has no translation', () => {
|
||||
const XLIFF = `<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
Reference in New Issue
Block a user