Skip to content

GoodRequest/i18nextJsonToCsv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON to CSV converter script for i18next translations

This scripts are converting JSON files which is generated by i18next to CSV file and also back from CSV to JSON files.

Implementation

First you need to install the module as dev dependency into you project.

npm install --save-dev @goodrequest/convert-translations-i18next

Example of script to convert from json to csv

npx convert-json-to-csv @goodrequest/convert-translations-i18next

Example of script to convert back from csv to json

npx convert-csv-to-json @goodrequest/convert-translations-i18next

This is what a config file looks like

{
        // csv delimiter which is used in CSV file, default value is ';'
	"csvDelimiter": ";",
	// path for csv file, default value is "/public/translations.csv"
	"filePathForGeneratedCSV": "/public/translations.csv",
	// the languages which you want to convert, default value is all files which scripts founds
	"supportedLanguages":["cz", "sk", "en"],
	// the json files which you want to convert, default value is all files which scripts founds
	"includeFiles": ["loc", "paths"],
	// path for json files which is generated by i18next scanner, default value is "/public/locales"
	"pathToDirectoryForLocales": "/public/locales"
}

Default config

{
  "csvDelimiter": ";",
  "filePathForGeneratedCSV": "/public/translations.csv",
  "pathToDirectoryForLocales": "/public/locales"
}

You can also use your own config file. First option is to add config file i18JsonToCsv.config.json in to root folder. Second option is to pass path to your config file using process environment CONFIG_PATH.

npx cross-env CONFIG_PATH=/scripts/configs/myConfig.json convert-csv-to-json GoodRequest/i18nextJsonToCsv

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •