dptran
English | 日本語版
dptran is a command-line tool and library for using the DeepL API, written in Rust.
Features
Binary CLI
- Translate via CLI, interactive input, pipeline, or file/editor input
- Support for multi-line input, output to file, and removing line breaks
- DeepL API Free / Pro support
- Language code lookup and character usage tracking
- Result caching
Library
- API client for DeepL translation
- Language code and usage queries
Installation
Binary crate
Library crate
Basic Usage
Set API Key
# or set env: export DPTRAN_DEEPL_API_KEY=[Your API key]
If you want to use DeepL Pro API key, set it like this:
# or set env: export DPTRAN_DEEPL_API_KEY_PRO=[Your API key]
Translate
# simple translation (translate to default target language)
# translate with target language
# translate with source language
# translate interactively
> Hello
# translate from a file and output to another file
# The file `translated.txt` will contain the translated text.
# translate with a pipeline
|
# translate with line breaks removed
# translate from an editor (like vim, emacs. must be set in config)
# Editor will open
Options
- -t [LANG] Set the default target language
- -f [LANG] Set the default source language
- -i [FILE] Input from file
- -o [FILE] Output to file
- -r Remove line breaks
- -u Show character usage
For more options and detailed usage, run:
Subcommands
list
: Show list of supported languages (-s for source languages, -t for target languages)config
: General settings such as default target language and editor commandapi
: API settings such as API keys and endpoint URLscache
: Cache settings such as enabling/disabling cache, setting max entries, and clearing cachehelp
: Print this message or the help of the given subcommand(s)
Configuration
Change default target language:
Reset all settings:
Setting API Endpoint
You can set the API endpoint URL using the api
subcommand:
Then you can use dptran with your own API endpoint, e.g., a local LLM server.
Note that the API endpoints must be compatible with the DeepL API specification.
Development & Testing
Run unit tests.
To run tests that require a real DeepL API key, set the environment variable DPTRAN_DEEPL_API_KEY
:
Some require dummy API server to be running.
The dummey server will be run at http://localhost:8000/
by default.
Documentation
Crate page: https://crates.io/crates/dptran
Library docs: https://docs.rs/dptran
License
Licensed under either of:
- MIT License
- Apache License 2.0
Release Notes
-
v2.3.3 (2025-09-07)
- Binary CLI: Add clear-all and show options to API settings, change config --clear-all to not reset these API settings
- Binary CLI: Improve error handling in
do_translation()
- Library: Modularize each API implementation in translate, languages, and usage
-
v2.3.2 (2025-07-07)
- Binary CLI: Fix issue where endpoint settings were not reflected in usage and lang commands
- Library: Fix query encoding when sending requests
-
v2.3.1 (2025-07-01)
- Binary CLI & Library: Any api endpoint can be used
- Binary CLI: Split
set
subcommand intoconfig
,api
, andcache
subcommands - Test: Use the python dummy API server for some tests