https://github.com/othree/i18ncsv2json
i18n csv file to json convetor
https://github.com/othree/i18ncsv2json
Last synced: 9 months ago
JSON representation
i18n csv file to json convetor
- Host: GitHub
- URL: https://github.com/othree/i18ncsv2json
- Owner: othree
- License: mit
- Created: 2016-01-20T07:30:48.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-10-16T10:50:56.000Z (over 8 years ago)
- Last Synced: 2025-09-29T03:49:01.416Z (9 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/i18ncsv2json
- Size: 10.7 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
i18ncsv2json
============
i18n csv file to json convetor.
Expect one or more csv file with following structure:
key | en | de
------|------------|------------
about | about here | etwa hier
home | homepage | Startseite
Execute following command:
i18ncsv2json tools.csv
Then will generate 2 files, one is `tools.en.json`:
{
"about": "about here",
"home": "homepage"
}
And one is `tools.de.json`:
{
"about": "etwa hier",
"home": "Startseite"
}
### Working with multiple files
Multiple files can be provided as arguments.
Execute following command:
i18ncsv2json tools.csv file.csv
Will generate 4 files:
- `tools.en.json`
- `tools.de.json`
- `file.en.json`
- `file.de.json`
Wildcard can also be used in path
i18ncsv2json *.csv
Output for the same language can be merge together into a single file with the `merge` option.
Execute following command:
i18ncsv2json tools.csv file.csv --merge
Will generate 2 files:
- `en.json`
- `de.json`
### Field delimiter
If you are working with English locale, the field delimiter in csv files is the `,` character. But for other locales (e.g. french) the `;` character is used. You can adapt the csv field delimiter with the `fieldDelimiter` option.
Example command to use semicolon:
i18ncsv2json directory -f ";"
### Encoding
It is possible to choose the encodings (for source csv files and output json files). This can typically be usefull when managing the csv files via excel which by default saves the file in windows specific encoding and not utf-8. Default output encoding is utf8.
Example command to use read csv file with Windows encoding and output it in utf16 :
i18ncsv2json directory -r latin1 -w utf16
Usage
-----
i18ncsv2json [options]
Options:
|Short flag|Flag |Description |
|----------|--------------------------|------------------------------------------------------------------------|
|-h |--help |output usage information |
|-V |--version |output the version number |
|-p |--path [value] |output path |
|-d |--delimeter [value] |delimeter between filename and lang |
|-t |--transpose |transpose input csv file |
|-f |--fieldDelimiter [value] |delimiter between fields |
|-r |--readEncoding [value] |encoding to use to read files |
|-w |--writeEncoding [value] |encoding to use to write files |
|-m |--merge |merge all csv files into a single json file |