Tools to manipulate XLIFF contents.
# Use npm
npm install @vtabary/xliff2js
# Or use yarn
yarn add @vtabary/xliff2jsConverts a XLIFF string into a JSON object.
var XliffParser = require('xliff2js').XliffParser;
var obj = new XliffParser().parse('</root><root>');
console.log(JSON.stringify(obj, undefined, 2));
// displays :
// { name: 'root', '$': {}, children: [] }No option available.
xmlan XLIFF valid as a string
Converts a JSON object to XLIFF string.
var XliffBuilder = require('xliff2js').XliffBuilder;
var str = new XliffBuilder({ pretty: true }).build({
name: 'xliff',
$: {},
children: [],
});
console.log(str);
// displays :
// '<?xml version="1.0"?><xliff/>'prettypretty prints the result. Default: falseindentindentation string. Default: ' 'newlinenewline sequence. Default: '\n'offseta fixed number of indentations to add to every line. Default: 0widthmaximum column width. Default: 0allowEmptydo not self close empty element tags. Default: falsedontPrettyTextNodesif any text is present in node, don't indent or LF. Default: falsespaceBeforeSlashadd a space before the closing slash of empty elements. Default: ''writerthe default XML writer to use for converting nodes to string. Default: the built-in XMLStringWriter
objecta JSON object matching