有新浪的域名怎么做网站,建设银行 网站用户变成个人用户,今天莱芜大事件新闻最新消息,商业网站建站google翻译api已经收费了#xff0c;而微软翻译api目前是免费的#xff0c;支持几种不同的方式访问#xff0c;如果感兴趣可以自己封装下协议处理。官方介绍#xff1a; http://msdn.microsoft.com/en-us/library/hh454950.aspx。 这里介绍一下java下的使用。Java下使用微软… google翻译api已经收费了而微软翻译api目前是免费的支持几种不同的方式访问如果感兴趣可以自己封装下协议处理。官方介绍 http://msdn.microsoft.com/en-us/library/hh454950.aspx。 这里介绍一下java下的使用。Java下使用微软翻译api可以直接使用一个开源的sdkhttp://code.google.com/p/microsoft-translator-java-api/。 一、首先去http://code.google.com/p/microsoft-translator-java-api/下载相关jar文件这里有对微软翻译api的详细使用有作详细介绍。 二去申请key进入http://www.bing.com/developers/createapp.aspx填写相关的你的应用信息就行了。就会有下面的图片中显示的key中的Application ID就是key。 三、下面给个实例 Java代码 /** * Title: MicroTranslate.java * Description: TODO(用一句话描述该文件做什么) * author zengzhaoshuai * date 2012-2-13 下午1:17:07 * version V1.0 */ import com.memetix.mst.language.Language; import com.memetix.mst.translate.Translate; /** * ClassName: MicroTranslate * Description: TODO(这里用一句话描述这个类的作用) * author zengzhaoshuai * date 2012-2-13 下午1:17:07 * */ public class MicroTranslate { public static void main(String[] args) throws Exception { // Set the Microsoft Translator API Key - Get yours at http://www.bing.com/developers/createapp.aspx // Translate.setKey(/* Enter your API Key here */); Translate.setKey(自己申请的key); String translatedText Translate.execute(属性, Language.CHINESE_SIMPLIFIED, Language.ENGLISH); System.out.println(translatedText); } } 四、运行结果Property 这里说下可能出现的问题 1、android下要用microsoft-translator-java-api-0.6-jar-with-dependencies.jar否则运行时可能会报错android java.lang.NoClassDefFoundError: org.json.simple.JSONValue。 2、使用过程中出现错误TranslateApiException: Cannot find an Azure Market Place Translator Subscription associated with the request credentials则需要到网址上先订阅translate api的免费流量操作如下 Make sure you login to azure market place click on data and select Microsoft Translator. Now click on 2000000 c/moth $0 update option. Now I think this error will go away. Try following link also. This is the link where I signed up for 2000000 c/month offer. I was facing the same problem but when I updated my account through following link, this error went away.参考http://social.msdn.microsoft.com/Forums/zh-CN/microsofttranslator/thread/1eeb0066-553f-4523-9a1b-0976e4205bb2转载于:https://www.cnblogs.com/brainy/archive/2012/05/24/2516487.html