Delphi 通过有道接口实现翻译


本文整理自网络,侵删。

 


function GetTranslatedText(const OriText: string): string;
var
  Json: TQJson;
const
  WebRestApiUrl = 'http://fanyi.youdao.com/translate?&doctype=json&type=AUTO&i=%s';
begin
  Json := TQJson.Create;
  try
    try
      Json.Parse(CSimpleGet(Format(WebRestApiUrl, [TURLEncoding.URL.Encode(OriText)]))); //CSimpleGet 这里可以搜索本站用 idhttp nethttpclient 实现获取
      Result := Json.ItemByPath('\translateResult[0][0]\tgt').AsString;
    except
      on e: Exception do
        Result := '';
    end;
  finally
    FreeAndNil(Json);
  end;
end;

感谢 黑夜杀手 提供

相关阅读 >>

Delphi datasnap(midas)三层架构中,常用事件及其触发顺序

Delphi stream对象

Delphi下cpu getcpuid实现(x86和x64)

Delphi 谷歌api文本转换语音mp3文件

Delphi tstrings类的一些技巧

Delphi 读取全网站链接

Delphi dataset和json互转函数

Delphi 调用api打开文件 使用系统默认打开方式进行打开

Delphi 文件查找记录类型 - tsearchrec

Delphi getwebbrowserhtml 获取网页源代码

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    正在狠努力加载,请稍候...