Skip to main content

Translate git commit messages to a target language using local or LLM-based translation

Project description

git-translate-commits

PyPI Python License: GPL v3 Tests

Translate git commit messages to a target language. Runs 100% offline by default using Argos Translate -- no API key, no cost. Optionally use LLM APIs for higher-quality contextual translation.

Why?

With LLM-powered coding assistants generating commits in mixed languages, repositories end up with inconsistent commit histories. This tool normalizes all commit messages to your preferred language in a single command.

Installation

The recommended way to install CLI tools is with pipx (isolated environment) or uv:

# Recommended: pipx (isolated install)
pipx install git-translate-commits

# Or: uv
uv tool install git-translate-commits

# Or: plain pip
pip install git-translate-commits

For LLM-based translation (optional):

pipx install "git-translate-commits[llm]"
# or: pip install "git-translate-commits[llm]"

For best rewrite performance, also install git-filter-repo:

pip install git-filter-repo

Quick Start

# Preview changes (offline, no API key needed)
git-translate-commits --lang en --dry-run

# Translate all commits on current branch to English (offline)
git-translate-commits --lang en

# Translate all branches to Brazilian Portuguese
git-translate-commits --lang pt-BR --all-branches

# Use LLM for higher quality (requires API key)
export OPENAI_API_KEY="sk-..."
git-translate-commits --lang en --engine llm

Translation Engines

Local (default) -- --engine local

Uses Argos Translate, an offline neural machine translation engine based on OpenNMT. Language packs (~50MB each) are downloaded automatically on first use.

  • No API key required
  • No cost
  • Fully offline after first download
  • Good quality for common language pairs

LLM -- --engine llm

Uses LLM APIs (OpenAI, Anthropic, or any OpenAI-compatible provider) for contextual translation via litellm. Requires pip install "git-translate-commits[llm]".

  • Higher quality contextual translations
  • Batch processing to minimize API calls and cost
  • A 1,000-commit repo costs ~$0.05 with gpt-4o-mini

Usage

git-translate-commits [OPTIONS]

Required

Option Description
--lang, -l Target language code (en, pt-BR, es, fr, de, ja, ...)

Engine

Option Default Description
--engine, -e local Translation engine: local (offline) or llm (API-based)

Filtering

Option Description
--all-branches Process all local branches
--branch, -b Specific branch(es) to process (repeatable)
--author Filter commits by author email
--since Only commits after this date
--until Only commits before this date

LLM Configuration (only with --engine llm)

Option Default Description
--provider, -p openai LLM provider (openai, anthropic, openai-compatible)
--model, -m gpt-4o-mini Model to use
--api-key env var API key (prefer OPENAI_API_KEY / ANTHROPIC_API_KEY env vars)
--api-base-url Base URL for OpenAI-compatible providers
--batch-size 20 Messages per LLM request

Behavior

Option Default Description
--dry-run, -n false Preview changes without modifying anything
--skip-already-translated true Skip messages already in target language
--backup true Create backup branch before rewriting
--preserve-conventional true Preserve Conventional Commit prefixes
--force, -f false Skip confirmation prompt
--verbose, -v false Show detailed logs

Environment Variables

# Engine and language
export GIT_TRANSLATE_ENGINE="local"   # or "llm"
export GIT_TRANSLATE_LANG="en"

# LLM-only settings
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
export GIT_TRANSLATE_PROVIDER="openai"
export GIT_TRANSLATE_MODEL="gpt-4o-mini"

Examples

# Offline translation (default) — no API key needed
git-translate-commits --lang en

# Translate commits by a specific author
git-translate-commits --lang en --author "dev@example.com"

# Translate commits from the last year
git-translate-commits --lang en --since "2025-01-01"

# Use LLM engine for better contextual quality
git-translate-commits --lang en --engine llm

# Use Anthropic Claude via LLM engine
git-translate-commits --lang en --engine llm --provider anthropic --model claude-sonnet-4-20250514

# Use a local OpenAI-compatible server (e.g. Ollama) via LLM engine
git-translate-commits --lang en --engine llm \
  --provider openai-compatible \
  --api-base-url http://localhost:11434/v1 \
  --model llama3

# Skip confirmation and backup
git-translate-commits --lang en --force --no-backup

What Gets Preserved

  • File contents — no code is touched
  • Author/committer — name, email, timestamps
  • Conventional Commit prefixesfeat:, fix:, chore:, etc.
  • Issue references#123, JIRA-456
  • Git trailersCo-authored-by, Signed-off-by, etc.

⚠️ Important Notes

  • Commit hashes will change. This is unavoidable since the message is part of the SHA hash. Coordinate with your team before force-pushing.
  • A backup branch is created automatically before any changes (disable with --no-backup).
  • A log file (.git-translate-log.json) is written with the full mapping of changes.
  • Local engine is free. LLM engine costs ~$0.05 per 1,000 commits with gpt-4o-mini.

Contributing

Contributions are welcome! Please read the Contributing Guide for details on how to get started.

Development

git clone https://github.com/paladini/git-translate-commits.git
cd git-translate-commits
pip install -e ".[dev]"
pytest

See CONTRIBUTING.md for full development guidelines.

License

This project is licensed under the GNU General Public License v3.0 -- see the LICENSE file for details.

Author

Created and maintained by Fernando Paladini.

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

git_translate_commits-1.0.1.tar.gz (35.7 kB view details)

Uploaded Source

Built Distribution

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

git_translate_commits-1.0.1-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: git_translate_commits-1.0.1.tar.gz
  • Upload date:
  • Size: 35.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for git_translate_commits-1.0.1.tar.gz
Algorithm Hash digest
SHA256 07cddeaaa6ce84ac9f586ae2225fe9c3c8a59ada29a425d9fb290bc64d2b83d0
MD5 77e27e9466b2c704a7fb31cd3995203c
BLAKE2b-256 37973b38fdb1c16800afd6b07393aed5459a12aca60a9a9f262ac8e8c05007ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_translate_commits-1.0.1.tar.gz:

Publisher: publish.yml on paladini/git-translate-commits

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for git_translate_commits-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b707b94bf22fe15b556bc703588a69f4c4aa18cd9de5c262cad1a27352c25a5c
MD5 2e849395bfae4af87cb60bb284aa9d9e
BLAKE2b-256 99577f9c3207b9262eefc42c3e83bf2fb02d2fe4e02e4421880938cb421cda55

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_translate_commits-1.0.1-py3-none-any.whl:

Publisher: publish.yml on paladini/git-translate-commits

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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