JounQin 7269cf615a fix(translate): answer blank texts with themselves instead of failing the request
A request fails as a whole when any one of its texts is empty, so a document
split into lines cannot be translated at all if it has a blank line in it:
["", "Hello"] answers 404 "No text to translate" and nothing is translated.

A blank text — empty, or nothing but whitespace — carries nothing to
translate, so it is no longer sent, and its own text is the answer. That
keeps the response position-aligned, and it is the only thing that can work:
oneshot echoes an empty input, and the positional check would read that echo
as a failed translation and answer 503 instead. A whitespace-only text
survives today only because oneshot happens to echo it as well.

The 404 is now only for a request with no text at all — no texts, or every
text empty. A request that has text but nothing to translate, like ["   "],
is answered with its own texts, so no blank input errors any more and no
input that used to succeed fails now.

This matches the JavaScript client (@deeplx/core batchPayload and
restoreBlankSegments), which already drops text.trim() === '' segments and
puts them back, so the two sides agree on what a blank segment means.

Refs #240, #241, #244.
2026-10-10 23:35:19 +08:00
2026-10-08 03:25:28 -07:00
2026-10-08 03:25:28 -07:00
2022-10-20 02:12:18 +08:00

DLX

GitHub Workflow Go Version Go Report GitHub License Docker Pulls Releases

Important

Disclaimer: DLX is an independent, open-source project. It is not an official DeepL product, and it is not affiliated with, endorsed by, or sponsored by DeepL SE in any way. "DeepL" is a registered trademark of DeepL SE. Any reference to DeepL in this repository is made solely to describe interoperability with the DeepL translation service.

Why was this project renamed?

In July 2026, we received a trademark notice forwarded by GitHub Trust & Safety, submitted on behalf of DeepL SE. The notice stated that this project's former name, "DeepLX", contained the registered trademark "DeepL" and might cause confusion about whether the project is authorized or endorsed by DeepL SE.

It never was, and it never claimed to be. To resolve the matter and remove any possible confusion, we renamed the repository to DLX and removed DeepL branding from the project. To state it plainly one more time: this project is not an official DeepL project and has no relationship with DeepL SE whatsoever.

DLX is a self-hosted translation API server written in Go. It exposes a simple HTTP API on port 1188.

Usage

Docker

Docker Hub and GHCR image names remain deeplx (only the GitHub repository was renamed to DLX):

docker run -d -p 1188:1188 ghcr.io/owo-network/deeplx:latest
# or: docker run -d -p 1188:1188 missuo/deeplx:latest

Or use the provided compose.yaml:

docker compose up -d

Binary

Download the binary for your platform from Releases and run it (artifact names remain deeplx_*):

./deeplx

Translate

text accepts either a single string or an array of strings. A string is answered with a string in data; an array is answered with a position-aligned array of the same length, and the whole batch travels in a single upstream request.

# Single text
curl -X POST http://localhost:1188/translate \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello, world!", "source_lang": "EN", "target_lang": "ZH"}'
{"alternatives":null,"code":200,"data":"你好,世界!","id":123,"method":"Free","source_lang":"EN","target_lang":"ZH"}
# Batch: one entry per text, answers come back in the same order
curl -X POST http://localhost:1188/translate \
  -H "Content-Type: application/json" \
  -d '{"text": ["Hello, world!", "Good morning"], "source_lang": "EN", "target_lang": "ZH"}'
{"alternatives":null,"code":200,"data":["你好,世界!","早上好"],"id":123,"method":"Free","source_lang":"EN","target_lang":"ZH"}

Batch limits and failure modes:

  • The anonymous limit is 1500 characters for the whole request, counted in UTF-16 code units — what JavaScript's String.prototype.length reports, so a CJK character costs 1 and an astral one (emoji, historic scripts) costs 2 — across every text in the array, not 1500 per text. A batch over that total is rejected with 413 and text exceeds maximum length: N characters (anonymous oneshot limit is 1500), so a large batch has to be chunked by total length rather than by segment count. There is no separate cap on the number of texts.
  • A blank text — empty, or nothing but whitespace — is answered with itself and never sent, so a blank line in a segmented document keeps its place instead of failing the request. A request with no text at all — no texts, or every text empty — is still rejected with 404 {"code":404,"message":"No text to translate"}.
  • A batch is all-or-nothing: if DeepL returns a different number of translations or leaves one of them empty, the request fails with 503 {"code":503,"message":"Translation failed"} instead of answering with placeholders or a shorter, misaligned array.

Discussion Group

Telegram Group

Acknowledgements

Contributors

Activity

Alt

License

MIT

S
Description
DeepL Free API (No TOKEN required)
Readme MIT
1.5 MiB
Languages
Go 94.7%
Shell 4.7%
Dockerfile 0.6%