如何使用谷歌API来翻译一个控制语言如何使用、语言、API

2023-09-06 18:21:27 作者:迷入感情路

我下载GoogleTranslateAPI.dll文件,并添加它的引用到我的项目。 现在,我参加了一个文本框,并写下约翰在里面,并采取了标签,并希望这样写:约翰的,但在法国的语言。所以我写了button_click事件......

I download the GoogleTranslateAPI.dll file and added the reference of it to my project. Now i took a textbox and wrote 'John' in it and took a label and want to be written 'John' in it but in 'French' language. So i wrote in the button_click event....

    private void button1_Click(object sender, EventArgs e)
    {
        string TT = Txt1.Text;

        Label1.Text=Google.API.Translate.Translator.Translate(TT, Google.API.Translate.Language.English,Google.API.Translate.Language.French);
    }

这给出了一个错误说翻译失败......谁能告诉我做错了什么? 这是一个桌面应用程序,并运行脱线。

This gives an error saying "TRANSLATE FAILED"... Can anyone tell what i did wrong ?? This is a desktop application and will run off line.

开发..

推荐答案

谷歌翻译API v2是目前的版本是(自2011年12月1日)仅提供的有偿服务 ...

Google Translate API v2 is the current version and is (since December 1, 2011) only available as a paid service...

反正访问API你需要注册与谷歌的关键和使用,在你的code你想要的方式。对于一些一般信息,请参阅http://$c$c.google.com/intl/en-US/apis/language/translate/v2/getting_started.html

Anyway to access the API the way you want to you need to register a key with Google and use that in your code. For some general information see http://code.google.com/intl/en-US/apis/language/translate/v2/getting_started.html

更新 - 根据意见和OP更新后的问题:

在谷歌API只能用于在线 - 你下载的DLL仅仅是一个围绕基于HTTP的服务器API的包装。

The Google API is only usable online - the DLL you downloaded is just a wrapper around the http-based server API.

如果你需要这个离线你将不得不使用字典对于任何您需要的语言对购买一些商业包装,并安装在本地...

IF you need to do this offline you will have to buy some commercial package with dictionaries for any language pairs you need and install that locally...