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

CSV & TSV Translation

The CSV/TSV handler (src/formats/csv_tsv.rs) translates delimited text files cell by cell while preserving the row/column structure and any header rows.

How It Works

  1. Read — The file is parsed using the csv crate. For TSV files the delimiter is changed to \t.
  2. Translate — Each non-empty cell value is sent to TranslationService::translate_text. Empty cells are passed through unchanged.
  3. Write — Translated cell values are written to the output file using the same delimiter and quoting rules as the input.

Because cell values are translated independently, the TranslationService cache is particularly effective here: repeated values (e.g. category names appearing in every row) are translated once and served from cache on subsequent rows.

Error Handling

Parsing errors from the csv crate are automatically converted to AppError::Csv via the From implementation in src/error.rs.

Limitations

  • The handler does not attempt to detect or skip header rows automatically. All cells, including headers, are sent for translation. If you want to preserve English headers, pre-process the file before passing it to TMT.
  • Cells exceeding MAX_REQUEST_TEXT_BYTES (5,000 characters) are chunked by TranslationService at sentence boundaries before being sent.