GUIDE
Installation
yarn add -D google-sheet-translation-sync npm install --save-dev google-sheet-translation-sync
credentials.json
Create google sheet app and download app https://developers.google.com/sheets/api/quickstart/nodejs
Add config file
- Should create a folder names
translation-sync
and puttranslation-sync.config.js
file in it translation-sync.config.js
examples:
const path = ;const languages = 'en' 'vi';const defaultLanguage = 'en'; moduleexports = credentialsPath: path tokenPath: path languages: languages defaultLanguage: defaultLanguage languagesRootPath: path languagePathPattern: '{{language}}/translation.json' header: 'note' 'key' ...languages spreadsSheetId: '1m2BEgWXkQm***' sheetName: 'Sheet1' range: 'A1:F1500' // Sheet range;
Folder structure
project-folder example translation-sync.config.js credentials.json # Google app credentials token.json # Generated when run pull or push for the first time package.json
.gitignore
Add credential.json
and token.json
to .gitignore
Example:
/example/credentials.json/example/token.json
CLI usage
pull
- Pull translations from Google Sheet
translation-sync pull --config ./custom-path/translation-sync.config.js
push
- Push translations from your project
translation-sync push --config ./custom-path/translation-sync.config.js
sort
- Sort server translations
- Sort by key
- Move rows that have non-empty note to the bottom
- Move rows that have empty or
__NOT_TRANSLATED__
language value to the bottom
translation-sync sort --config ./custom-path/translation-sync.config.js
API usage
const pull push sort = ;const config = ; ;;;