Example SpreadSheet https://docs.google.com/spreadsheets/d/1qjNcJ4JEonpwRKVtkR99TOHif1plFsr5jUW2bLXwmhM/
Prerequisite:
Node
Steps:
- Install the latest version of the package from npm as a dev dependency:
npm i -D sheet2i18n
- Create a
sheet2i18n.config.js
configuration file in your project's root directory:
my-app
├── node_modules
+ ├── sheet2i18n.config.js
└── package.json
- Add and edit config values of your newly created
sheet2i18n.config.js
:
module.exports = {
exportPath: <ExportPath>,
tabsUrl: Array<TabUrl>,
localesKey: Array<LocaleKey>,
};
Example:
module.exports = {
exportPath: "locales",
tabsUrl: [
"https://docs.google.com/spreadsheets/d/e/2PACX-1vR8qY9uP-jDrUMpZfk9BYk8qZZ7T-cj3xzEy9DAfauyVci_Od0qvG1EPTiYoNf-SpC_c4A04b54Jv8C/pub?gid=0&single=true&output=csv",
"https://docs.google.com/spreadsheets/d/e/2PACX-1vR8qY9uP-jDrUMpZfk9BYk8qZZ7T-cj3xzEy9DAfauyVci_Od0qvG1EPTiYoNf-SpC_c4A04b54Jv8C/pub?gid=229463273&single=true&output=csv",
],
localesKey: ["en", "fr", "es"],
};
Go to (Google Sheet -> File -> Share -> Publish to web) to generate Google Sheet CSV publish url.
- Add the command in the
scripts
section of yourpackage.json
to use thesheet2i18n
CLI:
[Default] ConfigPath: "sheet2i18n.config"
"scripts": {
+ "sheet2i18n": "sheet2i18n <ConfigPath>"
}
Example:
"scripts": {
+ "sheet2i18n": "sheet2i18n src/app/utilities/config.sheet2i18n"
}
Run the following command in console.
npm run sheet2i18n
- axios/axios - Promise based HTTP client for the browser and node.js.
- adaltas/node-csv - Full featured CSV parser with simple api and tested against large datasets.
/sheet2i18n
|--- node_modules/ <-- generated by npm install
|--- bin/ <-- binaries of the modules
|--- sheet2i18n.config.js <-- modules configurations example
|--- index.js <-- entry script
|--- package.json <-- defines build commands and dependencies
This project is licensed under the Apache 2.0 license - see the LICENSE file for details.