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.
- data/README +1 -1
- data/lib/google_translate.rb +9 -5
- metadata +1 -1
data/README
CHANGED
data/lib/google_translate.rb
CHANGED
@@ -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 => '
|
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
|
-
|
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
|
-
|
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
|