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.0.1.tar.gz (16.6 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.0.1-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gettranslated_cli-1.0.1.tar.gz
  • Upload date:
  • Size: 16.6 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.0.1.tar.gz
Algorithm Hash digest
SHA256 2a2325d53d37fbf874daa191a151e7b1999df549ac4ae1a75afc04f0daaf4a57
MD5 852ccd579266b63610a6541b949d50a2
BLAKE2b-256 51eda86c362d4d4e9c6d77595485e962b686ac9f3306c8d599ec1de52e96f0e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gettranslated_cli-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5599d129dde981a103009c81059cf46b9be7dec15e44dac7ba203a6a6e8a1fa7
MD5 a8dd07a46925d34e996606ab8744c8bd
BLAKE2b-256 cfff825a9c74b657029da4b78d67fbfa21f1b2305e348c62a9b7fc7a09881b11

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