fix(compiler): assert xliff messages have translations
fixes #12815 closes #12604
This commit is contained in:
parent
9ed9ff40b3
commit
7908679c4b
@ -190,7 +190,11 @@ class XliffParser implements ml.Visitor {
|
|||||||
this._addError(element, `Duplicated translations for msg ${id}`);
|
this._addError(element, `Duplicated translations for msg ${id}`);
|
||||||
} else {
|
} else {
|
||||||
ml.visitAll(this, element.children, null);
|
ml.visitAll(this, element.children, null);
|
||||||
this._mlNodesByMsgId[id] = this._unitMlNodes;
|
if (this._unitMlNodes) {
|
||||||
|
this._mlNodesByMsgId[id] = this._unitMlNodes;
|
||||||
|
} else {
|
||||||
|
this._addError(element, `Message ${id} misses a translation`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -113,6 +113,24 @@ export function main(): void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('structure errors', () => {
|
describe('structure errors', () => {
|
||||||
|
it('should throw when a trans-unit has no translation', () => {
|
||||||
|
const XLIFF = `<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
|
||||||
|
<file source-language="en" datatype="plaintext" original="ng2.template">
|
||||||
|
<body>
|
||||||
|
<trans-unit id="missingtarget">
|
||||||
|
<source/>
|
||||||
|
</trans-unit>
|
||||||
|
</body>
|
||||||
|
</file>
|
||||||
|
</xliff>`;
|
||||||
|
|
||||||
|
expect(() => {
|
||||||
|
loadAsMap(XLIFF);
|
||||||
|
}).toThrowError(/Message missingtarget misses a translation/);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should throw when a trans-unit has no id attribute', () => {
|
it('should throw when a trans-unit has no id attribute', () => {
|
||||||
const XLIFF = `<?xml version="1.0" encoding="UTF-8" ?>
|
const XLIFF = `<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
|
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user