1.0.4 • Published 3 years ago

json-from-gsheet v1.0.4

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years ago

Sheet template: https://docs.google.com/spreadsheets/d/1TA79qZ0TVai4XwFH4OUbmxIfxndnp9p09x7lh9MweqQ/edit?usp=sharing

Installation

yarn add json-from-gsheet   

or

npm i json-from-gsheet

Usage:

spreadsheetId - You can get it from the spreadsheet url which is placed after /spreadsheets/d/. Ex: spreadsheets/d/{YOUR_SPREADSHEET_ID}.
apiKey - get it from your Google Console. Learn more.
tabName - tab name in your spreadsheet, which is shown on the bottom of the page. Ex: Sheet1.
savePath - the path where you want to store your translation files.

const { sheetToJSON } = require('json-from-gsheet')


sheetToJSON({
    spreadsheetId: 'SPREADSHEET_ID',
    apiKey: 'API_KEY',
    tabName: 'TAB_NAME',
    savePath: 'PATH_TO_SAVE_FILES'
})

Example:

sheetToJSON({
    spreadsheetId: 'SPREADSHEET_ID',
    apiKey: 'API_KEY',
    tabName: 'TAB_NAME',
    savePath: './src/i18n/locales'
})

Output:

It outputs languages.json file in the root folder of the path you passed.

Then it outputs all [language].json files in the passed path.

Here is how [language].json looks like after it is parsed from the sheet