You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google Translate Cloud API罗马化泰卢固语翻译结果与网页端不一致问询

Google Cloud Translate API拉丁转写泰卢固语翻译异常解决方法
  • 异常根因:网页/移动端Google翻译默认适配了拉丁转写(音译)的小语种识别逻辑,但Cloud Translate API默认仅处理对应语种的原生文字输入,你当前调用的返回结果中API自动检测到的源语言为te(指代原生泰卢固文),与输入的拉丁字母内容不匹配,因此直接返回原文。
  • 第一步:切换使用Google Cloud Translate V3版本API,V2版本不支持转写语种的翻译能力。
  • 第二步:调用时显式指定源语言参数为te-Latn,明确告知API输入为拉丁转写形式的泰卢固语,关闭自动源语言检测功能。
    修改后的调用示例(V3版本):
from google.cloud import translate_v3 as translate

client = translate.TranslationServiceClient()
project_id = "你的GCP项目ID"
location = "global"
parent = f"projects/{project_id}/locations/{location}"

response = client.translate_text(
    request={
        "parent": parent,
        "contents": ["parishkaram chesamu"],
        "mime_type": "text/plain",
        "source_language_code": "te-Latn",
        "target_language_code": "en",
    }
)

for translation in response.translations:
    print(translation.translated_text)
  • 第三步:验证返回结果,上述调用会正确返回We have solved,和网页端翻译结果一致。
  • 特殊情况排查:如果指定te-Latn后仍然返回原文,检查GCP控制台中Cloud Translation API的「高级翻译功能」是否已启用,同时确认账号对应项目的API配额未耗尽、权限配置正确。

内容的提问来源于stack exchange,提问作者Aditya Jayanti

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.23 17:45:01