Class: Translator
- Inherits:
-
Object
- Object
- Translator
- Defined in:
- lib/t2etranslator.rb
Class Method Summary collapse
Class Method Details
.translate(context, default = "ta") ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/t2etranslator.rb', line 5 def self.translate(context, default = "ta") begin page = Nokogiri::HTML(open(URI.parse(URI.encode("http://translate.google.com/?langpair=en|#{default}&text=#{context}")))) result = page.search("#result_box") result.text rescue SocketError context end end |