A CLI build tool to generate JSON files required by Angular Translate from a single CSV file
npm install angular-translate-csv-to-jsonusers.create.labelFirstName will produce a nested JSON structure.
json
{
"users": {
"create": {
"labelFirstName": "First Name",
"labelLastName": "Last Name"
},
"toastValidationEmailSentToUserEmail": "Validation email sent to {{userEmail}}"
}
}
`
$3
` json
{
"users": {
"create": {
"labelFirstName": "Prénom",
"labelLastName": "Nom"
},
"toastValidationEmailSentToUserEmail": "E-mail de validation envoyé à {{userEmail}}"
}
}
`
Note: Output JSON will not be pretty-printed as above, but compact.
Installation
` bash
npm install angular-translate-csv-to-json --save-dev
`
Usage
` bash
node node_modules/angular-translate-csv-to-json config/angular-translate-csv-to-json.config.json
`
The first (and only) parameter is the path to a config file, which is required.
Configuration:
This is an example configuration you can adapt to your needs:
` json
{
"csvFileIn": "src/angular/i18n/translations.tsv",
"jsonDirOut": "src/angular/i18n",
"jsonFileName": "translations",
"jsonExt": "json",
"csvFieldSeparator": "\t"
}
`
$3
#### csvFileIn
Type: String
The path to the input CSV file to be processed.
#### jsonDirOut
Type: String
Output directory to store the generated JSON files in.
#### jsonFileName
Type: String
The first part of the JSON file name. The file name is constructed as the following: {jsonFileName}.{languageCode}.{jsonFileExt} (e.g. translations.en.json, translations.fr.json, etc.)
#### jsonFileExt
Type: String
The extension of the generated JSON file.
#### csvFieldSeparator
Type: String`