OwO-Network/DeepLX

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

Closed this issue · 2 comments

我看 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."
    }
  ]
}

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

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.