"Too many text segments" Google 翻译错误 API

"Too many text segments" error in Google translate API

我在 Angular-12 工作。在我们的系统中,我们使用“Google 翻译”API.

所以当我们尝试批量翻译字符串时,API returns 错误

 {
  "error": {
    "code": 400,
    "message": "Too many text segments",
    "errors": [
      {
        "message": "Too many text segments",
        "domain": "global",
        "reason": "invalid"
      }
    ]
  }
}

这是我们在 API、

中发送的数据类型

API 我们正在使用 https://translation.googleapis.com/language/translate/v2?key=Alza.......

 {
        "source":"en",
        "target":"es",
        "q":["string1", "string1",......]
    }

任何形式的帮助都是合适的,谢谢。

如本documentation所述,每个请求可发送翻译的字符串(段)总数限制为128。如果发送翻译的段数超过128,则错误“ API 将抛出太多文本段”。引用提到的文档:

The maximum number of strings is 128.

作为替代,Cloud Translation Advanced can be used. It offers higher limits on the number of strings that can be sent for translation. Cloud Translation Advanced also provides support for glossaries, batch requests, and AutoML models. A comparison between the Basic and Advanced versions of the Translation API can be found here