The problem arises when there are trailing whitespaces in the source document segments. When importing, SDL Studio separates them from the text and moves into separate structures. E.g., if the source segment is "Hello ", the exported translated xliff will look like:
createUnit function of xliff2js saves the last child of the element. When it is <ignorable> rather than <segment>, the resulting source and target are empty as they are copied from <ignorable>. I believe this can be fixed by adding a check for element name.
function createUnit (unit, initValues) {
// source, target, note
return unit.elements.reduce((unit, segment) => {
if (segment.name === 'segment') { // <------- check if it is a segment and not an ignore section
segment.elements.forEach((element) => {
switch (element.name) {
case 'source':
case 'target':
case 'note':
unit[element.name] = extractValue(element.elements, ElementTypes2)
break
}
})
}
return unit
}, JSON.parse(JSON.stringify(initValues)))
}
Hello!
The problem arises when there are trailing whitespaces in the source document segments. When importing, SDL Studio separates them from the text and moves into separate structures. E.g., if the source segment is "Hello ", the exported translated xliff will look like:
createUnit
function ofxliff2js
saves the last child of the element. When it is<ignorable>
rather than<segment>
, the resulting source and target are empty as they are copied from<ignorable>
. I believe this can be fixed by adding a check for element name.