xliff-generator
Reads from an source file the translation keys and their corresponding translation values and creates the xliff file (here).
Currently only csv is supported.
License
The MIT License. See the license file for details.
Build
$ npm run build-dev # build module incl. source maps $ npm run build # build module (for production - no source maps), run eslint and execute unit tests
Testing
$ npm test
Install
$ npm install --save xliff-generator
Usage
sync
'use strict'; const xliffGenerator = ; try xliffGenerator; catch err // An error occured... console;
async
'use strict'; const xliffGenerator = ; xliffGenerator;
Parameters
Parameter | Mandatory | Default Value | Description |
---|---|---|---|
csvFile | yes | -- | The path to the csv file |
productName | yes | -- | The product name used in the resulting xlif file |
printPretty | no | false |
If true the resulting xml file will be printed pretty (see also here) |
csvDelimiter | no | ',' |
The csv delimiter. Exactly one character has to be entered (see also here) |
csvComment | no | '' |
The csv comment character. Zero or one character has to be entered (see also here) |
csvEscape | no | '"' |
The csv escape character. Exactly one character has to be entered (see also here) |
csvQuote | no | '"' |
The csv quote character. Exactly one character has to be entered (see also here) |
languageOptions | yes | -- | The supported languages. Exactly one element has to be a source language (the boolean value of the isSourceLanguage has to be true ) |
Parameters: languageOptions
Parameter | Mandatory | Default Value | Description |
---|---|---|---|
isSourceLanguage | depends | false |
true if the language is a source language. See also parameter languageOptions |
languageKey | yes | -- | The language key. See also at the structure of the csv file |
output | yes | -- | Path where the resulting xml file of the language will be stored |
Structure of the csv file
Header
The first row of the csv file contains the header information. The first column of the header contains the translation id. The following colums contains the language keys e.g. en
, de
etc.. The values of the language keys must match with the entered values of the languageOptions
.
The following rows contains per row exactly one translation values.
Example
key,en,de
errorMessage.error1,Error message 1,Fehlermeldung 1
errorMessage.error2,Error message 2,Fehlermeldung 2
Example of a xml file
Error message 1 Error message 2