首页 > 解决方案 > 如何在 Android 上使用谷歌翻译 API?

问题描述

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

这样做的首选方法是什么?

标签: androidgoogle-translate

解决方案


请看这个链接

这个怎么运作?

它需要三个参数,将要翻译的文本、源语言和目标语言。它在后台执行翻译并返回一个带有结果的字符串

特征

  • 使用 Google Cloud Translation API 翻译文本
  • 只有一堂简短的课程,因此易于使用和理解

一个例子:

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();

更新

另请查看此文档github

希望对您有所帮助。


推荐阅读