Traduz textos usando o google
Traduz palavras/frases/textos usando a API do Google, usei aqui http://github.com/rafaelss/shoes-translator
1 require 'rest_client' 2 require 'json' 3 require 'cgi' 4 5 word = CGI.escape("hello world") 6 response = RestClient.get "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=#{word}&langpair=en%7Cpt" 7 json = JSON.parse(response) 8 status = json['responseStatus'] 9 if status == 200 10 puts json['responseData']['translatedText'] 11 else 12 puts "(#{responseStatus}) erro ao traduzir #{word}" 13 end