Module: I27r::BabelFish

Defined in:
lib/generators/i18n_translation/lib/translator.rb

Instance Method Summary collapse

Instance Method Details

#_translate(word, lang) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/generators/i18n_translation/lib/translator.rb', line 13

def _translate(word, lang)
  require 'mechanize'
  w = CGI.escape ActiveSupport::Inflector.humanize(word)

  agent = Mechanize.new
  url = "http://babelfish.yahoo.com/translate_txt?lp=en_#{lang}&trtext=#{w}"
  page = agent.get(url)
  page.search('#result div').text
end