No commit activity in last 3 years
No release in over 3 years
a ruby wrapper for youdao fanyi api
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0
 Project Readme

YoudaoFanyiAPI

A ruby wrapper for youdao fanyi api.

Installation

Add this line to your application's Gemfile:

gem 'youdao_fanyi_api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install youdao_fanyi_api

Usage

First you need to configure the API

YoudaoFanyiAPI.configure do |config|
  config.key     = YOUR_KEY
  config.keyfrom = YOUR_KEYFROM
end

Then, you can use translate method.

puts YoudaoFanyiAPI.translate('hello world')['translation'] # 你好,世界

You could use a client

client = YoudaoFanyiAPI::Client.new(key: YOUR_KEY, keyfrom: YOUR_KEYFROM)
puts client.t('ruby')['basic']['explains']
# n. 红宝石;红宝石色
# adj. 红宝石色的
# ...

You can also use t method, which is an alias of translate. The translate method returns a hash, you can find more details from here. translate also has a second optional argument, using as client.t('hello', only: true), which will only show dictionay result.

Contributing

Feel free to file an issue or send a pr.