Tools to manipulate XLIFF contents.
# Use npm
npm install @vtabary/xliff2js
# Or use yarn
yarn add @vtabary/xliff2js
Converts 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.
xml
an 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/>'
pretty
pretty prints the result. Default: falseindent
indentation string. Default: ' 'newline
newline sequence. Default: '\n'offset
a fixed number of indentations to add to every line. Default: 0width
maximum column width. Default: 0allowEmpty
do not self close empty element tags. Default: falsedontPrettyTextNodes
if any text is present in node, don't indent or LF. Default: falsespaceBeforeSlash
add a space before the closing slash of empty elements. Default: ''writer
the default XML writer to use for converting nodes to string. Default: the built-in XMLStringWriter
object
a JSON object matching