android - 如何在 Android 上使用谷歌翻译 API?
问题描述
我正在尝试在一个安卓应用程序中使用谷歌翻译 API。不幸的是,我找不到合理的方法来做到这一点,因为谷歌云 java 客户端目前不支持安卓!
这样做的首选方法是什么?
解决方案
请看这个链接
这个怎么运作?
它需要三个参数,将要翻译的文本、源语言和目标语言。它在后台执行翻译并返回一个带有结果的字符串
特征
- 使用 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();
更新:
希望对您有所帮助。
推荐阅读
- node.js - 执行存储过程 NJS-012 时出现 node-oracledb 错误
- docker - Docker Content Trust“离线”可能/合理?
- c# - 将实体映射到模型
- javascript - 在 laravel 5.6 中使用 ajax 发布图片
- combobox - 如何使用数据库(TornadoFX)中的信息更新自动完成组合框建议列表?
- angular - 将“构造”放在组件上时,模板不会加载 Angular 2
- android - 如何在android中将背景图像转换为灰度?
- jupyter-notebook - 是否可以将我笔记本电脑上运行的 jupyter 与 google colab 连接起来
- azure - 是否可以通过 HTTP 请求标头确认机器人的身份?
- arrays - 检查 sub 是否返回 undef