i18n-sheet-json
This is the library to read Google Sheet and create JSON locale files in your output directory
Installation
npm install i18n-sheet-json
or
yarn add i18n-sheet-json
Google credential
Service Account
- Go to the Google Developers Console
- Select your project or create a new one and then select it
- Enable the Drive API for your project
- Expand APIs & auth > APIs
- Search for "drive"
- Click on "Drive API"
- Click on "Enable API" button
- Create a service account
- expand APIs & auth > Credentials
- Click on the "Add credentials" button
- Select the "Service account"
- Select the "JSON" key type option
- Click on "Create" button
Your JSON key file is generated and downloaded to your machine.
How to Implement
e.g. some-file.js
// Import the libraryconst worksheet = // Add google credential fileconst credentials = // Setup configurationconst config = // Credential is a json file that you got from Google credentials:credentials languages:LANGUGE_CODE_AS_ARRAY sheet:'DOCUMENT_ID_AS_STRING' output_dir:'PATH_AS_STRING' // ADD CONFIG HEREworksheet// READ Google Sheet and create JSON locale files in your output directoryworksheet // On the otherhands you can specify the worksheet withworksheet// You can also use parameter as arrayworksheet
How to use
Just run node some-file.js
Google Sheet
The google sheet has constructed like this. You can make locale columns and worksheets as much as you need.
id | th | en | other.. |
---|---|---|---|
title | สวัสดี | Hello | ... |