Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration

API Token

TMT requires an API token to communicate with the TMT translation service. You can supply it in one of two ways:

Via environment variable (recommended):

export TMT_API_TOKEN=your_secret_token_here

Or place it in a .env file in the project root (a template is provided at .env_example):

TMT_API_TOKEN=your_secret_token_here

Via CLI argument (overrides the environment variable):

tmt --api-token your_secret_token_here ...

Runtime Validation

Before translation begins, all CLI arguments are transformed into a RuntimeConfig struct via TryFrom<&Cli>. This process enforces the following rules — any violation exits with a descriptive error:

RuleDetails
API token must be presentFails with AppError::MissingApiToken if neither --api-token nor TMT_API_TOKEN is set, or if the value is whitespace-only.
Concurrency ≥ 1--concurrency 0 is rejected with an InvalidArgument error.
Source and target languages must differ--src-lang en --tgt-lang en is rejected (case-insensitive check).
DPI ≥ 1Applies to PDF output only.
JPEG quality in range [1, 100]Applies to PDF output only.
Font path must existIf --font-path is provided, the path must point to an existing file.

Example Usage

Translate a CSV from English to Nepali

tmt \
  --input data.csv \
  --output data_ne.csv \
  --src-lang en \
  --tgt-lang ne

Translate a DOCX from Nepali to English

tmt \
  --input document.docx \
  --output document_en.docx \
  --src-lang ne \
  --tgt-lang en

Translate a PDF (requires pdf feature)

PDF translation requires a TrueType or OpenType font for rendering the target script, especially for Devanagari:

tmt \
  --input report.pdf \
  --output report_ne.pdf \
  --src-lang en \
  --tgt-lang ne \
  --font-path /usr/share/fonts/truetype/Noto/NotoSansDevanagari-Regular.ttf