<?xml version="1.0" encoding="utf-8" ?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file date="2020-02-11T14:49:15Z" source-language="fr" target-language="es" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
</header>
<body>
<trans-unit id="a1" resname="item1">
<source>item1</source>
<target>Transaltion 1</target>
</trans-unit>
<trans-unit id="a2" resname="item2">
<source>item2</source>
<target>Translation 2</target>
</trans-unit>
</body>
</file>
</xliff>
import xliff from 'xliff'
const fileEs = fs.readFileSync(`${ROOT_DIR}/src/models/refs/test.xlf`, 'utf-8')
;(async () => {
try {
const result = await xliff.xliff2js(fileEs)
console.log(result)
} catch (e: any) {
// general error here
console.log(e)
}
})()
Error:
ts-node src/models/refs/xliff.ts
TypeError: Cannot read properties of undefined (reading 'id')
🐛 Bug Report
The following error occurs on seamingly valid XLIFF files (using https://dev.maxprograms.com/Validation/ to validate).
To Reproduce
Xliff contents:
Error:
Expected behavior
A JSON valid output (or a readable error).
Your Environment