Skip to main content

A modern command-line translator powered by LLMs

Project description

dtrans

PyPI version

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.

image

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.1.tar.gz (97.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.1-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dtrans-1.0.1.tar.gz
  • Upload date:
  • Size: 97.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.1.tar.gz
Algorithm Hash digest
SHA256 2a4deaa87e4b21527ec8728ed06a651d51f45fbe2e0ca2be2b1e74f40f4a630b
MD5 60b5841ce9433bf66e4fa0d9a0494d5e
BLAKE2b-256 53b7ed78ddee43bd9beb77123ed75e1ffc05fef686b033c150dc145cc7702e65

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtrans-1.0.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: dtrans-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 91680677ac33362ffd86dd6a8e575027ebe4fb3f9ffc78c23663d07f09bfe016
MD5 b090d381fe009aff35993f582444bf25
BLAKE2b-256 6b87e6d2ebb572f55aac7c58b801f54ff1e25f6cf547ef5013b11d30fbc16185

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtrans-1.0.1-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