OwO-Network / DeepLX

Powerful Free DeepL API, No Token Required
https://ssa.sx/deeplx
MIT License
6.68k stars 534 forks source link

批量翻译返回格式和官方不一致 #114

Closed yujinqiu closed 6 months ago

yujinqiu commented 6 months ago

我看 DeepL 官方支持 https://developers.deepl.com/docs/api-reference/translate#large-volumes

curl -X POST http://localhost:1188/v2/translate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your_access_token" \
-d '{
    "text": [
      "This is the first sentence.",
      "This is the second sentence.",
      "This is the third sentence."
    ],
    "target_lang": "DE"
}'

执行返回内容

{"translations":[{"detected_source_language":"EN","text":"Dies ist der erste Satz.\nDies ist der zweite Satz.\nDies ist der dritte Satz."}]}

官方的例子返回

{
  "translations": [
    {
      "detected_source_language": "EN",
      "text": "Das ist der erste Satz."
    },
    {
      "detected_source_language": "EN",
      "text": "Das ist der zweite Satz."
    },
    {
      "detected_source_language": "EN",
      "text": "Dies ist der dritte Satz."
    }
  ]
}
missuo commented 6 months ago

What's wrong with that? Officially, you have to traverse the whole array, but you're still traversing the whole array, just one element.

yujinqiu commented 6 months ago

What's wrong with that? Officially, you have to traverse the whole array, but you're still traversing the whole array, just one element.

@missuo The background is I already develop my app which support official DeepL API, if DeepLX response is the same format, I don't need additional logic to handle the different.