Download
The source is available for download from
GitHub.
Alternatively, you can install using npm:
npm install --save xliff
You can then require()
xliff as normal:
const xliff = require('xliff');
Or you can direclty require()
its functions:
const xliff2js = require('xliff/xliff2js');
Usage
const xliff = `<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en-US" trgLang="de-CH">
<file id="namespace1">
<unit id="key1">
<segment>
<source>Hello</source>
<target>Hallo</target>
</segment>
</unit>
<unit id="key2">
<segment>
<source>An application to manipulate and process XLIFF documents</source>
<target>Eine Applikation um XLIFF Dokumente zu manipulieren und verarbeiten</target>
</segment>
</unit>
<unit id="key.nested">
<segment>
<source>XLIFF Data Manager</source>
<target>XLIFF Daten Manager</target>
</segment>
</unit>
</file>
</xliff>`;
const js = {
"resources": {
"namespace1": {
"key1": {
"source": "Hello",
"target": "Hallo"
},
"key2": {
"source": "An application to manipulate and process XLIFF documents",
"target": "Eine Applikation um XLIFF Dokumente zu manipulieren und verarbeiten"
},
"key.nested": {
"source": "XLIFF Data Manager",
"target": "XLIFF Daten Manager"
}
}
},
"sourceLanguage": "en-US",
"targetLanguage": "de-CH"
};
const xliff2js = require('xliff/xliff2js');
xliff2js(xliff, (err, res) => {
});
const js2kliff = require('xliff/js2kliff');
js2kliff(js, (err, res) => {
});
const targetOfjs = require('xliff/targetOfjs');
targetOfjs(js, (err, res) => {
});
const sourceOfjs = require('xliff/sourceOfjs');
sourceOfjs(js, (err, res) => {
});
const createjs = require('xliff/createjs');
createjs(
js.sourceLanguage,
js.targetLanguage,
{
"key1": "Hello",
"key2": "An application to manipulate and process XLIFF documents",
"key.nested": "XLIFF Data Manager"
},
{
"key1": "Hallo",
"key2": "Eine Applikation um XLIFF Dokumente zu manipulieren und verarbeiten",
"key.nested": "XLIFF Daten Manager"
}
'namespace1',
(err, res) => {
});
const createkliff = require('xliff/createkliff');
createkliff(
js.sourceLanguage,
js.targetLanguage,
{
"key1": "Hello",
"key2": "An application to manipulate and process XLIFF documents",
"key.nested": "XLIFF Data Manager"
},
{
"key1": "Hallo",
"key2": "Eine Applikation um XLIFF Dokumente zu manipulieren und verarbeiten",
"key.nested": "XLIFF Daten Manager"
}
'namespace1',
(err, res) => {
});