xlf-translate
Advanced tools
Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "xlf-translate", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Populate XLIFF (.XLF) files with existing translations", | ||
@@ -5,0 +5,0 @@ "main": "translate.js", |
@@ -5,2 +5,7 @@ 'use strict'; | ||
const indent = node => { | ||
const indent = node.parent().html().match(/^\s+/); | ||
return indent !== null ? indent[0] : ''; | ||
}; | ||
/** | ||
@@ -18,7 +23,17 @@ * Fills in translations in XLIFF files based on 'meaning' metadata as a key. | ||
units | ||
.filter(unit => doc(unit).find('note').length > 0) | ||
.map(unit => ({ | ||
target: doc(unit).find('target'), | ||
id: doc(unit).find('note[from=meaning]').text() | ||
})) | ||
.map(unit => doc(unit)) | ||
.filter(unit => unit.find('note').length > 0) | ||
.map(unit => { | ||
const source = unit.find('source'); | ||
let target = unit.find('target'); | ||
if (target.length === 0 && source.length === 1) { | ||
target = doc('<target />'); | ||
source.after(indent(source), target); | ||
} | ||
return { | ||
target: target, | ||
id: doc(unit).find('note[from=meaning]').text() | ||
}; | ||
}) | ||
.filter(d => d.id && isKey(d.id)) | ||
@@ -25,0 +40,0 @@ .forEach(d => { |
8434
48