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.0.tar.gz (36.0 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.0-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: git_translate_commits-1.0.0.tar.gz
  • Upload date:
  • Size: 36.0 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.0.tar.gz
Algorithm Hash digest
SHA256 c1f2672a824bc59fc46257d92e9fd9ee4dde6ca2ab0d70386b1cd7334be553ad
MD5 c5f3b5a98f582abf3dffdd26b728f798
BLAKE2b-256 496d16b0936c39e841009113057de3af3695cd8765b924935534996bcd010d4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_translate_commits-1.0.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for git_translate_commits-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66b8bea493f816cf7437cc854326c2f4ebaeb9000903616090278b051641b6d3
MD5 2d3749de166119d04dfb3e48fe4d8f94
BLAKE2b-256 9f6e22843066f1c8eea7d39fc8903867dd90b400b2b13927f3751aae46019159

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_translate_commits-1.0.0-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