【问题标题】:Translate and detect at same time using Google Translate API使用 Google Translate API 同时翻译和检测
【发布时间】:2018-03-05 13:54:12
【问题描述】:

我想使用谷歌翻译 API 来检测输入的语言并获得翻译,但根据 docs here 似乎这是不可能的。

有人知道这是否可能吗?还是我必须打两个电话? 谢谢

【问题讨论】:

标签: google-translate


【解决方案1】:

您当然可以同时检测和翻译您的内容。更具体地说,它会自动检测源语言,而无需指定源语言,只需调用翻译API方法translate()

【讨论】:

  • 谢谢大家。我试过了,效果很好:)。我只需要在查询 url 中保留源代码。
【解决方案2】:

可以不指定源语言,只指定目标语言,直接调用 translate 方法。下面是使用代码的代码 sn-p 谷歌云翻译 jar。效果很好

    Translate translate = getTranslationServiceClient();

    // Translates some text into target language
    Translation translation = translate.translate("Hello", TranslateOption.targetLanguage("hi"));

【讨论】:

    猜你喜欢
    • 2013-02-11
    • 2021-10-03
    • 2014-04-21
    • 2015-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多