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.2.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.2-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dtrans-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 fde276b29185f482db00460c17ddb13262e44b3ff33f259eb58babda0c55cb4c
MD5 ec3a7ee33123d0a25265cee1b2aca0bf
BLAKE2b-256 88e99d05e66ecea097c90ba9d0bf3a67327ddcf2216d25955d92c06417602891

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dtrans-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cc7664d676268b6cd0efa23ce9dd1427eda9452c2fa50f7579628cc667b297e3
MD5 ff781e588f6e0d9c5e61aad44db084f5
BLAKE2b-256 1dfcc2264db61c049c82592403c1da64517bb9d73c92f0959e80cfbf710facd7

See more details on using hashes here.

Provenance

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