4 Star 0 Fork 0

Gitee 极速下载 / youdao-fanyi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/zhhailon/youdao-fanyi
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Youdao Fanyi

This is a Youdao Fanyi API wrapper written in Ruby.

Youdao Fanyi is a translation service provided by Youdao.

Pre Job

Before coding, you should go to Youdao Fanyi API for an API key.

Caution: Each key can request less than 1000 times per hour.

Example

# coding: UTF-8
# example.rb
require 'youdao-fanyi'
# Configure the key first
YoudaoFanyi::Config.key_from = "youdao-fanyi"
YoudaoFanyi::Config.key = 1629987369
# Then use the 4 methods provided.
to_be_translated = "要翻译的词句"
YoudaoFanyi.search_json(to_be_translated)       # returns a JSON string
YoudaoFanyi.search_xml(to_be_translated)        # returns an XML string
YoudaoFanyi.search_jsonp(to_be_translated)      # returns a JSONP string
YoudaoFanyi.search_result_obj(to_be_translated) # returns a YoudaoFanyi::Result object

About the API

Youdao Fanyi API provides 3 types of data: xml, json and jsonp.

Here is an xml sample:

http://fanyi.youdao.com/fanyiapi.do?keyfrom=&key=&type=data&doctype=xml&version=1.1&q=这里是有道翻译API

<?xml version="1.0" encoding="UTF-8"?>
<youdao-fanyi>
	<errorCode>0</errorCode>
	<!-- 有道翻译 -->
	<query><![CDATA[这里是有道翻译API]]></query>
	<translation>
    	<paragraph><![CDATA[Here is the youdao translation API]]></paragraph>
	</translation>
</youdao-fanyi>

Here is a json sample:

http://fanyi.youdao.com/fanyiapi.do?keyfrom=&key=&type=data&doctype=json&version=1.1&q=翻译

{
	"errorCode":0
    "query":"翻译",
	"translation":["translation"], // 有道翻译
	"basic":{ // 有道词典-基本词典
	    "phonetic":"fān yì",
	    "explains":[
	        "translate",
	        "interpret"
	    ]
	},
	"web":[ // 有道词典-网络释义
	    {
	        "key":"翻译",
	        "value":["translator","translation","translate","Interpreter"]
	    },
	    {...}
	]
}

Here is a jsonp sample:

http://fanyi.youdao.com/fanyiapi.do?keyfrom=&key=&type=data&doctype=jsonp&callback=show&version=1.1&q=API

show({
	"errorCode":0
	"query":"API",
	"translation":["API"], // 有道翻译
	"basic":{ // 有道词典-基本词典
	    "explains":[
	        "abbr. 应用程序界面(Application Program Interface);..."
	    ]
	},
	"web":[ // 有道词典-网络释义
	    {
	        "key":"API",
	        "value":["应用程序接口(Application Programming Interface)","应用编程接口","应用程序编程接口","美国石油协会"]
	    },
	    {...}
	]
});

Contributors

  • ZHANG Hailong [https://github.com/zhhailon]

空文件

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Ruby
1
https://gitee.com/mirrors/youdao-fanyi.git
git@gitee.com:mirrors/youdao-fanyi.git
mirrors
youdao-fanyi
youdao-fanyi
master

搜索帮助

14c37bed 8189591 565d56ea 8189591