Module: I27r::BabelFish
- Included in:
- Translator
- Defined in:
- lib/generators/i18n/translation/lib/translator.rb
Instance Method Summary collapse
Instance Method Details
#_translate(word, lang) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/generators/i18n/translation/lib/translator.rb', line 25 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 |