google_translate 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README +1 -1
  2. data/lib/google_translate.rb +9 -5
  3. metadata +1 -1
data/README CHANGED
@@ -1,6 +1,6 @@
1
1
  = Google::Translate
2
2
 
3
- http://goog_trl.rubyforge.org
3
+ http://googletrl.rubyforge.org/
4
4
 
5
5
  == Description
6
6
  The library is a simple API in Ruby for Google Translate service[http://translate.google.com/translate_t].
@@ -27,7 +27,7 @@ module Google
27
27
  :hi => { :in => 'iso-8859-13', :out => 'utf-8', :lang => 'Hindi' },
28
28
  :ro => { :in => 'iso-8859-2', :out => 'utf-8', :lang => 'Romanian' },
29
29
  :"zh-CN" => { :in => 'gb18030', :out => 'utf-8', :lang => 'Chinese Simplified' },
30
- :"zh-TW" => { :in => 'bit5', :out => 'utf-8', :lang => 'Chinese Traditional' } }
30
+ :"zh-TW" => { :in => 'big5', :out => 'utf-8', :lang => 'Chinese Traditional' } }
31
31
 
32
32
  URL = "http://translate.google.com/translate_t"
33
33
 
@@ -55,8 +55,13 @@ module Google
55
55
  "sl" => from,
56
56
  "tl" => to,
57
57
  "text" => text).search("#result_box").inner_html
58
-
59
- Iconv.new(LANG[to.to_sym][:out], LANG[to.to_sym][:in]).iconv(result)
58
+
59
+ return case self.user_agent
60
+ when /mechanize/i
61
+ Iconv.new(LANG[to.to_sym][:out], LANG[to.to_sym][:in]).iconv(result)
62
+ when /^[^www]/i
63
+ result
64
+ end
60
65
  end
61
66
 
62
67
  def new(*args)
@@ -65,8 +70,7 @@ module Google
65
70
 
66
71
  # Returns the languages' names, their abbreviations and Google encoding.
67
72
  def self.languages
68
- langs = LANG.sort_by{ |e| e[1][:lang] }
69
- langs.each{ |e| print e[0], "\t", e[1][:lang], "\n" }
73
+ LANG.sort_by{ |e| e[1][:lang] }
70
74
  end
71
75
  end
72
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_translate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vidul Nikolaev Petrov