如何在Android上使用google翻译API?

How to use google translation API on Android?

我正在尝试在安卓应用程序中使用 google 翻译 API。不幸的是,我找不到合理的方法来做到这一点,因为 google 云 java 客户端目前不支持 andriod!

执行此操作的首选方法是什么?

请看这个link

如何运作?

需要翻译的文本、源语言和目标语言三个参数。它在后台执行翻译,returns 一个带有结果

的字符串

特点

  • 使用 Google Cloud Translation 翻译文本 API
  • 只有一个短class因此易于使用和理解

示例:

GoogleTranslate googleTranslate = new GoogleTranslate();
// Perform the translation by invoking the execute method, but first save the result in a String.
// The second parameter is the source language, the third is the terget language
String result = googleTranslate.execute("the text to be translated", "en", "de").get();

更新:

另请查看此 documentation and in github

希望对你有所帮助

Cloud Translation API 作为 REST API 公开,如 documentation 所示,因此您可以将它与您最喜欢的 Android HTTP 库一起使用.

你也可以试试Phrase Phrase 提供了一种使用不同翻译引擎或您选择的选项将用户生成的内容翻译成所需目标语言的方法。