Home/i18nexus-tools/i18n-download
๐Ÿ“ฅ

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.

โœ“Preserve Existing Local Translations
โœ“Safely Merge Only Changes from Sheets
โœ“Automatic Conflict Resolution
โœ“Display Detailed Change Log

Basic Usage

Use Config File

If Google Sheets information is set in i18nexus.config.json:

npx i18n-download

Use Command Line Options

npx i18n-download \
  --spreadsheet-id "YOUR_SPREADSHEET_ID" \
  --credentials "./credentials.json"

How it works

1

Fetch Sheets Data

Reads all translation data from Google Sheets.

2

Read Local Data

Reads existing local translation files.

3

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
4

Save File

Saves merged results to local files and displays change log.

Command Options

--spreadsheet-idString

Google Sheets Spreadsheet ID (required)

--credentialsString

Google Cloud service account credentials JSON file path (required)

--sheet-nameString

Sheet name to read (default: "Translations")

--locales-dirString

Directory 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 updated

Safety 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.

Next Steps