Skip to main content

A modern command-line translator powered by LLMs

Project description

dtrans

A modern command-line translator powered by LLMs.

Note: This is a ground-up rewrite of translate-shell with a focus on LLM-based translation and a significantly improved CLI experience.

Features

  • LLM-powered translation via DeepSeek, Gemini, ChatGPT, or any OpenAI-compatible API
  • Verify your translations with alternatives, comparisons, and contextual examples
  • Rich terminal UI with beautiful panels, tables, and spinners
  • Modern CLI with explicit long-form flags and intuitive language syntax
  • Configurable providers via a simple TOML config file

Installation

pipx install dtrans

Or with pip:

pip install dtrans

Quick Start

  1. Create your configuration file at ~/.config/dtrans/config.toml:
default_provider = "deepseek"

[providers.deepseek]
api_key = "sk-..."
model = "deepseek-chat"

[providers.openai]
api_key = "sk-..."
model = "gpt-4o"

[providers.gemini]
api_key = "..."
model = "gemini-1.5-flash"
  1. Translate:
# Auto-detect source, translate to French
dtrans --to fr "Hello, world!"

# Specify source and target
dtrans en:fr "Hello, world!"

# Brief mode (translation text only)
dtrans --brief "Hello, world!"

# Identify language
dtrans --identify "手紙"

Usage

Usage: dtrans [OPTIONS] TEXT

Options:
  --from TEXT       Source language code (e.g. 'en', 'ja'). Omit to auto-detect.
  --to TEXT         Target language code (e.g. 'fr', 'zh'). Defaults to system locale.
  --provider TEXT   Override the default provider from the config file.
  --brief / --verbose
                    Brief mode prints only the translation. Verbose is the default in a TTY.
  --identify        Identify the source language and exit.
  --version         Show version and exit.
  --help            Show this message and exit.

Language Syntax

Pattern Meaning
:fr Auto-detect source → French
ja: Japanese → default target
en:fr English → French

Custom Providers

Any OpenAI-compatible API can be configured:

[providers.local]
base_url = "http://localhost:11434/v1"
api_key = "ollama"
model = "llama3"

Development

# Clone
git clone https://github.com/kriss-spy/deep-translate-shell.git
cd deep-translate-shell

# Install in editable mode with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Lint
ruff check src tests
mypy src

License

See LICENSE.

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

dtrans-1.0.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

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

dtrans-1.0.0-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dtrans-1.0.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dtrans-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2b93c4602ad15dcde35db61fa121d5737fc97d468c40b3f87bd79ccf3490e6d5
MD5 230bc33e8f75da2849abd135d0129514
BLAKE2b-256 aec215123390362cd4e23f8c46929c4b7eb0c96baa71e98a959e29dcc915301c

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtrans-1.0.0.tar.gz:

Publisher: publish.yml on kriss-spy/deep-translate-shell

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

File details

Details for the file dtrans-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dtrans-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dtrans-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b814bc4afc0929e123c535452fff3e09bceb1641d83def56a7567bf11a627abf
MD5 39522c62a684defcc1ad8f87452d2a66
BLAKE2b-256 375bf5778414993998bc4f566e556cabc516cca72ad305f9794e2a42e6aba7eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtrans-1.0.0-py3-none-any.whl:

Publisher: publish.yml on kriss-spy/deep-translate-shell

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