Skip to content

Instantly share code, notes, and snippets.

@wmeister-old
Created December 1, 2012 15:58
Show Gist options
  • Save wmeister-old/4182995 to your computer and use it in GitHub Desktop.
Save wmeister-old/4182995 to your computer and use it in GitHub Desktop.
require 'json'
require 'open-uri'
module EnglishToNorwegian
def self.translate(str)
JSON.parse(open("http://translate.google.com/translate_a/t?client=t&text=#{URI.escape(str)}&hl=en&sl=en&tl=no&ie=UTF-8&oe=UTF-8&multires=1&prev=btn&ssel=4&tsel=4&sc=1").read.gsub(/\,+/, ","))[0].collect{|a| a[0]}.join " "
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment