Permalink
Browse files

modify bin/youdao_fanyi load order

  • Loading branch information...
1 parent 27ea18b commit c30d475a12dca0812671a13f7908f0f198c762af @vkill committed Dec 2, 2011
Showing with 14 additions and 11 deletions.
  1. +4 −0 CHANGELOG
  2. +3 −2 README.markdown
  3. +4 −6 bin/youdao_fanyi
  4. +2 −2 examples/translate.rb
  5. +1 −1 lib/youdao_fanyi/version.rb
View
@@ -1,3 +1,7 @@
+== 0.1.1
+
+* modify bin/youdao_fanyi require load order, run fast
+
== 0.1.0
* First release
View
@@ -25,7 +25,7 @@ more see `examples/translate.rb`.
]
end
- puts YoudaoFanyi.t("china")
+ puts YoudaoFanyi.t("i love you")
YoudaoFanyi::Translator.translate("china", :i, nil, true, false, "") do |results|
p [results.error_code, results.translation, results.query]
@@ -70,8 +70,9 @@ When your want translate models attributes, please use https://github.com/vkill/
##Use in shell
- > # youdao_fanyi --key 2022446265 --keyfrom blog-vkill-net "详细" i you
+ > youdao_fanyi --key 2022446265 --keyfrom blog-vkill-net 中国 "i love you"
+If you want use proxy, please set `HTTP_PROXY`, link this `export HTTP_PROXY=http://localhost:8118`.
##Copyright
View
@@ -1,10 +1,5 @@
#!/usr/bin/env ruby
require "optparse"
-
-require "pp"
-$:.push File.expand_path("../../lib", __FILE__)
-require "youdao_fanyi"
-
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: youdao_fanyi [--key API_Key] [--keyfrom API_KeyFrom] STRING [STRING, ...]"
@@ -33,6 +28,10 @@ STDERR.puts "fanyi.youdao.com API key is required" unless options[:key]
STDERR.puts "fanyi.youdao.com API keyfrom is required" unless options[:keyfrom]
STDERR.puts "At least one string to translate is required" unless ARGV.size >= 1
+require "pp"
+$:.push File.expand_path("../../lib", __FILE__)
+require "youdao_fanyi"
+
YoudaoFanyi.configure do |config|
config.api_keys = [
{ "keyfrom" => options[:keyfrom], "key" => options[:key] }
@@ -41,7 +40,6 @@ end
YoudaoFanyi::Translator.translate(*ARGV) do |results|
# puts results.translation
- puts "======================================="
pp results.results
puts "======================================="
end
View
@@ -10,7 +10,7 @@
]
end
-puts YoudaoFanyi.t("china")
+puts YoudaoFanyi.t("i love you")
puts "======================================="
YoudaoFanyi::Translator.translate("中国", "china", :i, nil, true, false, "") do |results|
@@ -24,7 +24,7 @@
=begin
[root@vkill-arch youdao_fanyi]# ruby examples/translate.rb
-中国
+我爱你
=======================================
[0, "China", "中国"]
{"translation"=>["China"],
@@ -1,6 +1,6 @@
#encoding: utf-8
module YoudaoFanyi
- VERSION = "0.1.0"
+ VERSION = "0.1.1"
end

0 comments on commit c30d475

Please sign in to comment.