@vtabary/xliff2js
v0.6.1
Published
Tools to manipulate XLIFF contents.
Downloads
50
Readme
@vtabary/xliff2js
Tools to manipulate XLIFF contents.
Installation
# Use npm
npm install @vtabary/xliff2js
# Or use yarn
yarn add @vtabary/xliff2js
Class: XliffParser
Converts a XLIFF string into a JSON object.
Usage
var XliffParser = require('xliff2js').XliffParser;
var obj = new XliffParser().parse('</root><root>');
console.log(JSON.stringify(obj, undefined, 2));
// displays :
// { name: 'root', '$': {}, children: [] }
constructor()
Options
No option available.
#parse(xml: string): IXliff
Options
xml
an XLIFF valid as a string
Class: XliffBuilder
Converts a JSON object to XLIFF string.
Usage
var XliffBuilder = require('xliff2js').XliffBuilder;
var str = new XliffBuilder({ pretty: true }).build({
name: 'xliff',
$: {},
children: [],
});
console.log(str);
// displays :
// '<?xml version="1.0"?><xliff/>'
constructor(options)
Options
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
#build(object: IXliff): string
Options
object
a JSON object matching