Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorCazanave committed Jan 19, 2020
1 parent de092d4 commit e2bd941
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,45 @@

Generate i18n JSON/JS files from a Google Sheets spreadsheet

:warning: **WIP: Do NOT use for production**
## Installation

### npm

`npm install --save-dev google-sheets-i18n-generator`

### yarn

`yarn add --dev google-sheets-i18n-generator`

## Usage

1. Create a Google Sheets spreadsheet to store the i18n strings
2. Enable the Google Sheets API following [this documentation](https://developers.google.com/sheets/api/quickstart/nodejs#step_1_turn_on_the)
3. Download the `client_secret.json` and `credentials.js` files to access the Google Sheets API
3. Copy the ID of the spreadsheet (e.g. in this URL `https://docs.google.com/spreadsheets/d/1kjNb2-Tpn_1Pcd6pid22fBQlr8nd6oa1ltXwKNj1Gz11/edit#gid=0` the ID is `1kjNb2-Tpn_1Pcd6pid22fBQlr8nd6oa1ltXwKNj1Gz11`)
4. Run the command: `gs-i18n --spreadsheet <id>`
5. The JSON files are generated in the `./locales` folder

## API

```
Usage: gs-i18n --spreadsheet <id> [options]
Options:
-v, --version output the version number
-c, --client <path> path of client secret file (defaults to ./client_secret.json)
-f, --format <format> format of generated files (available values are cjs, esm and json, defaults json)
-k, --key <index> index of key column (defaults 0)
-l, --lang <index> index of first language column (defaults 1)
-o, --output <path> path of output directory (defaults to ./locales)
-r, --range <range> range of data to parse (defaults Sheet1)
-s, --spreadsheet <id> id of spreadsheet to parse (required)
-t, --token <path> path of credentials file (defaults to ./credentials.json)
-h, --help output usage information
```

## TODO

* Improve documentation
* Create unit tests
* Improve code
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const DEFAULT_TOKEN = './credentials.json'

// Generate documentation and parse arguments
program
.name("gs-i18n")
.usage('--spreadsheet <id> [options]')
.version(module.exports.version, '-v, --version')
.option(
'-c, --client <path>',
Expand Down

0 comments on commit e2bd941

Please sign in to comment.