Skip to main content

Command-line tool for syncing translations with GetTranslated.ai

Project description

GetTranslated CLI

Command-line tool for syncing translation files with GetTranslated.ai.

Installation

pip install gettranslated-cli

Quick Start

  1. Get your API key from your project settings

  2. Configure your API using the server key (choose one method):

    # Option 1: Environment variable
    export GETTRANSLATED_KEY="your-api-key-here"
    
    # Option 2: Project config file (recommended)
    echo "your-api-key-here" > .gettranslated
    
    # Option 3: Command line (not recommended for production)
    translate sync -k your-api-key-here
    
  3. Run a sync from your project directory:

    cd /path/to/your/project
    translate sync
    

That's it! The CLI will:

  • Upload your base language files
  • Translate any new or untranslated strings
  • Download all translated files to your project

Usage

Basic Commands

# Full sync (upload → translate → download)
translate sync

# Upload only
translate upload

# Download only
translate download

# Translate only
translate translate

# Grammar check
translate grammar

Options

# Specify working directory (default: current directory)
translate sync /path/to/project

# Verbose output
translate sync -v

# Force re-upload even if files haven't changed
translate sync -f

# Custom server URL
translate sync -s https://custom-server.com

Supported Platforms

  • Android: Automatically finds strings.xml files in values/ and values-XX/ directories
  • iOS: Automatically finds Localizable.strings and Localizable.stringsdict files in XX.lproj/ directories
  • React Native: Searches for JSON files in common locations:
    • locales/
    • src/locales/
    • assets/locales/
    • translations/
    • i18n/
    • Root directory

API Key Configuration

The CLI looks for your API key in the following order (first match wins):

  1. Command line argument (-k or --key)
  2. Environment variable (GETTRANSLATED_KEY)
  3. Project config file (.gettranslated in project directory)

Security Note

⚠️ Important: Add .gettranslated to your .gitignore to avoid committing your API key:

echo ".gettranslated" >> .gitignore

Examples

First-time Setup

# 1. Install the CLI
pip install gettranslated-cli

# 2. Set your API key
export GETTRANSLATED_KEY="your-key-here"

# 3. Navigate to your project
cd ~/projects/my-app

# 4. Run your first sync
translate sync

CI/CD Integration

# GitHub Actions example
name: Sync Translations

on:
  workflow_dispatch:
  schedule:
    - cron: '0 0 * * *'  # Daily at midnight

jobs:
  sync-translations:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.x'
      
      - name: Install GetTranslated CLI
        run: pip install gettranslated-cli
      
      - name: Run translation sync
        env:
          GETTRANSLATED_KEY: ${{ secrets.GETTRANSLATED_KEY }}
        run: translate sync .

Troubleshooting

"No API key found" error

Make sure you've configured your API key using one of the methods above. Check that:

  • Environment variables are set correctly
  • Config files exist and contain the key
  • You're running the command from the correct directory

"No [Platform] files found to upload"

Ensure your project structure matches the expected format:

  • Android: app/src/main/res/values/strings.xml
  • iOS:
    • XX.lproj/Localizable.strings (traditional format)
    • XX.lproj/Localizable.stringsdict (plurals format)
  • React Native: JSON files in one of the common locations

Connection errors

  • Verify your internet connection
  • Check that the server URL is correct (default: https://www.gettranslated.ai)
  • Ensure your API key is valid and has access to the project

Command Reference

translate <mode> [working_directory] [options]

Modes:
  upload      Upload base language files to server
  download    Download translated files from server
  translate   Trigger translation of untranslated strings
  sync        Run upload → translate → download (recommended)
  grammar     Run grammar check on project strings

Options:
  -k, --key KEY       Server API key
  -v, --verbose       Verbose output mode
  -f, --force         Force processing even if unchanged
  -s, --server URL    Server URL (default: https://www.gettranslated.ai)
  -h, --help          Show help message

License

MIT License

Support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gettranslated_cli-1.1.0.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gettranslated_cli-1.1.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file gettranslated_cli-1.1.0.tar.gz.

File metadata

  • Download URL: gettranslated_cli-1.1.0.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for gettranslated_cli-1.1.0.tar.gz
Algorithm Hash digest
SHA256 99cc1ccab6ade404ebdb34dc5779afb034bf08e02eef2e243d90ad876fc60860
MD5 868048ed6e2c80052b7a6f8a7187127d
BLAKE2b-256 47f149f05fb9741107640d79625354ff08cdfb17e041d3347d9676946ea8ad56

See more details on using hashes here.

File details

Details for the file gettranslated_cli-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gettranslated_cli-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc06b32999dc5fb85fe71cf9a6908837f90fc45b4e4abde352e0ef8ff1ea7287
MD5 324c29088d6b3c39fd05d7e2af2b8db2
BLAKE2b-256 34ef184c0b6625b7ed465478b81a5a18c241ad967b83d7c563699e157235c5e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page