如何使用谷歌翻译API在我的Java应用程序? [英] How to use Google Translate API in my Java application?

查看:1453
本文介绍了如何使用谷歌翻译API在我的Java应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我通过一个字符串(英文或阿拉伯文)作为输入到 <强>谷歌翻译API ,应该把它翻译成相应的语言等,给翻译的字符串给我。

If I pass a string (either in English or Arabic) as an input to the Google Translate API, it should translate it into the corresponding other language and give the translated string to me.

我读了一个论坛,同一个案件,但落实对我来说是很困难的。结果
我需要翻译,没有任何按钮,如果我给输入的字符串应该自动翻译的价值,并给输出。

I read the same case in a forum but it was very hard to implement for me.
I need the translator without any buttons and if I give the input string it should automatically translate the value and give the output.

您可以帮帮忙?

推荐答案

使用<一个href=\"http://$c$c.google.com/p/java-google-translate-text-to-speech/\">java-google-translate-text-to-speech而不是谷歌翻译API的Java V2

与谷歌的Java中翻译的主要特点阿比非官方的。

Api unofficial with the main features of Google Translate in Java.

它还提供文本到语音的API。如果你想要的文字翻译你好!在罗马尼亚只写:

It also provide text to speech api. If you want to translate the text "Hello!" in Romanian just write:

Translator translate = Translator.getInstance();
String text = translate.translate("Hello!", Language.ENGLISH, Language.ROMANIAN);
System.out.println(text); // "Bună ziua!" 

这是免费的!

作为@ r0ast3d正确地说:

It's free!

As @r0ast3d correctly said:

重要提示:谷歌翻译API第2版现在可作为一个付费服务。现有的翻译之前,8月24日创建API V2项目的赠送额度,2011年将在2011年另外12月1日降至零,你的应用程序每天可发出请求的数量将是有限的。

Important: Google Translate API v2 is now available as a paid service. The courtesy limit for existing Translate API v2 projects created prior to August 24, 2011 will be reduced to zero on December 1, 2011. In addition, the number of requests your application can make per day will be limited.

这是正确的:刚才看到官方页面

This is correct: just see the official page:

谷歌翻译API可作为一种有偿服务。请参阅定价和FAQ页面了解详情。

Google Translate API is available as a paid service. See the Pricing and FAQ pages for details.

BUT ,<一个href=\"http://$c$c.google.com/p/java-google-translate-text-to-speech/\">java-google-translate-text-to-speech是免费的!

我已经创建了一个证明该工作的示例应用程序。在这里试试吧:<一href=\"https://github.com/IonicaBizau/text-to-speech\">https://github.com/IonicaBizau/text-to-speech

I've created a sample application that demonstrates that this works. Try it here: https://github.com/IonicaBizau/text-to-speech

这篇关于如何使用谷歌翻译API在我的Java应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆