mirror of
https://github.com/OwO-Network/DeepLX.git
synced 2026-12-01 14:57:52 +00:00
fix(translate): answer a request whose texts are all empty with 200 as well
Every text is answered now, blank or not, so the all-empty case needs no rule of its own: "" and [""] are texts with nothing to translate in them, and they are answered with themselves like any other blank text. A missing or null `text` decodes to the one empty string and is answered the same way. The 404 is left for a request that names no text at all: `"text": []`, the one shape there is nothing to answer with. Nothing else errors on emptiness. Refs #244.
This commit is contained in:
@@ -90,7 +90,7 @@ curl -X POST http://localhost:1188/translate \
|
||||
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 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. Only a request that names no text at all, `"text": []`, is 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
|
||||
|
||||
Reference in New Issue
Block a user