you are in: codestackercodes [RSS] → tag: rest [RSS]

Traduz textos usando o google Delicious

Traduz palavras/frases/textos usando a API do Google, usei aqui http://github.com/rafaelss/shoes-translator

show/hide lines
   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
created by rafaess — 03 July 2008 — get a short url — tags: api google json rest ruby tradutor embed