首先,可以到http://code.google.com/p/microsoft-translator-java-api/这里下载Java类库。它有两种类型,一个是包含所有依赖的,一个是不包含依赖的。我下载的是包含依赖的,方便好用。
然后,在到这里https://datamarket.azure.com/account 取得你的clientid和secret。当然,前面你会经过一系列的注册登陆等流程。弄好之后,再点击这个页面就能看到如下的东西了:
16
上图中的“主帐户密钥”和“客户 ID”就是我们要的了。
然后按照那个翻译Java类库的代码,把id和密钥填入,如下,就能实现翻译了:
import com.memetix.mst.language.Language;
import com.memetix.mst.translate.Translate;
public class Main {
public static void main(String[] args) throws Exception {
// Set your Windows Azure Marketplace client info - See http://msdn.microsoft.com/en-us/library/hh454950.aspx
Translate.setClientId(/* Enter your Windows Azure Client Id here */);
Translate.setClientSecret(/* Enter your Windows Azure Client Secret here */);
String translatedText = Translate.execute("Bonjour le monde
然后,在到这里https://datamarket.azure.com/account 取得你的clientid和secret。当然,前面你会经过一系列的注册登陆等流程。弄好之后,再点击这个页面就能看到如下的东西了:
16
上图中的“主帐户密钥”和“客户 ID”就是我们要的了。
然后按照那个翻译Java类库的代码,把id和密钥填入,如下,就能实现翻译了:
import com.memetix.mst.language.Language;
import com.memetix.mst.translate.Translate;
public class Main {
public static void main(String[] args) throws Exception {
// Set your Windows Azure Marketplace client info - See http://msdn.microsoft.com/en-us/library/hh454950.aspx
Translate.setClientId(/* Enter your Windows Azure Client Id here */);
Translate.setClientSecret(/* Enter your Windows Azure Client Secret here */);
String translatedText = Translate.execute("Bonjour le monde

最低0.47元/天 解锁文章
3384

被折叠的 条评论
为什么被折叠?



