i18n-download
Safely downloads translations from Google Sheets to local
Overview
i18n-downloadis a CLI tool that downloads translations from Google Sheets to local JSON files. It preserves existing translations using an incremental update method and merges safely.
Basic Usage
Use Config File
If Google Sheets information is set in i18nexus.config.json:
npx i18n-downloadUse Command Line Options
npx i18n-download \
--spreadsheet-id "YOUR_SPREADSHEET_ID" \
--credentials "./credentials.json"How it works
Fetch Sheets Data
Reads all translation data from Google Sheets.
Read Local Data
Reads existing local translation files.
Smart Merge
Intelligently merges two data sources:
- โขKeys existing in Sheets: Values updated
- โขLocal-only keys: Kept as is
- โขNew keys in Sheets: Added locally
Save File
Saves merged results to local files and displays change log.
Command Options
--spreadsheet-idStringGoogle Sheets Spreadsheet ID (required)
--credentialsStringGoogle Cloud service account credentials JSON file path (required)
--sheet-nameStringSheet name to read (default: "Translations")
--locales-dirStringDirectory to save translation files (default: "./locales")
Example Output
$ npx i18n-download --spreadsheet-id "1abc...xyz"
๐ฅ Downloading translations from Google Sheets...
๐ Reading from Sheets...
Spreadsheet: "i18n Translations"
Sheet: "Translations"
โ Found 130 translation keys
Languages: ko, en
๐ Reading local files...
โ locales/ko.json (125 keys)
โ locales/en.json (125 keys)
๐ Merging translations...
โ Updated: 3 keys
โ Added: 5 new keys
โ Preserved: 122 local keys
๐พ Saving files...
โ locales/ko.json (130 keys)
โ locales/en.json (130 keys)
โ
Download complete!
Total keys: 130
Changes: +5 new, ~3 updatedSafety Features
Prevent Data Loss
- โPreserve Local Translations
Translation keys that exist only locally are never deleted.
- โAutomatic Conflict Resolution
If the same key exists in both, Sheets value takes priority.
- โBackup Recommended
Using version control like Git allows you to restore to a previous state at any time.
i18n-download vs i18n-download-force
๐ฅi18n-download
- โIncremental Update
- โPreserve Local Translations
- โSafe Merge
- โUse Regularly
๐ก Use this in most cases
๐i18n-download-force
- โขFull Overwrite
- โขDelete Local Translations
- โขSheets = Single Source of Truth
- โขUse with Caution
โ ๏ธ Use Only in Special Cases
Best Practices
โ Download Regularly
Download regularly after translators complete their work to keep translations up-to-date.
โ Git Commit
After downloading, commit changes to Git to share with team members.
โ Review Changes
Review the change log output after downloading to check for unexpected changes.