i18n-upload
Uploads local translation files to Google Sheets
Overview
i18n-uploadis a CLI tool that uploads local translation JSON files to Google Sheets. It's the first step for collaborating on translations with team members.
Basic Usage
Use Config File
If Google Sheets information is set in i18nexus.config.json:
npx i18n-uploadUse Command Line Options
npx i18n-upload \
--spreadsheet-id "YOUR_SPREADSHEET_ID" \
--credentials "./credentials.json"Command Options
--spreadsheet-idStringGoogle Sheets Spreadsheet ID (required)
Check in Sheets URL: https://docs.google.com/spreadsheets/d/[SPREADSHEET_ID]/edit
--credentialsStringGoogle Cloud service account credentials JSON file path (required)
--credentials "./credentials.json"--sheet-nameStringSheet name to upload (default: "Translations")
--sheet-name "MyTranslations"--locales-dirStringTranslation file directory (default: "./locales")
--locales-dir "./src/translations"Upload Process
Read Local Files
Reads all JSON files in the locales directory.
Data Conversion
Converts JSON data to Google Sheets format. First row becomes language codes, first column becomes translation keys.
Update Sheets
Clears existing data in Google Sheets and completely replaces it with new data.
Complete
Displays statistics along with upload completion message.
Precautions
โ ๏ธData Overwrite
- โขi18n-upload completely deletes existing data in Google Sheets and replaces it with new data
- โขIf you have translations modified directly in Sheets, back them up first
- โขGenerally used only once during initial project setup
- โขAfterwards, use i18n-download to fetch translations from Sheets
Example Output
$ npx i18n-upload --spreadsheet-id "1abc...xyz"
๐ค Uploading translations to Google Sheets...
๐ Reading local files...
โ locales/ko.json (125 keys)
โ locales/en.json (125 keys)
๐ Converting to Sheets format...
Languages: ko, en
Total keys: 125
๐ Updating Google Sheets...
Spreadsheet: "i18n Translations"
Sheet: "Translations"
โ Cleared existing data
โ Uploaded 126 rows (including header)
โ
Upload complete!
๐ View: https://docs.google.com/spreadsheets/d/1abc...xyzBest Practices
โ Use Only for Initial Setup
Upload only once at project start, then proceed with translation work in Sheets.
โ Verify Before Upload
Make sure local translation files are up-to-date before uploading.
โ Share with Team
After uploading, share the Sheets URL with team members to start translation work together.