Skip to content

Instantly share code, notes, and snippets.

@jewel12
Created October 12, 2010 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jewel12/622403 to your computer and use it in GitHub Desktop.
Save jewel12/622403 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# Google 翻訳
require 'rubygems'
require 'json'
require 'open-uri'
URL = "http://ajax.googleapis.com/ajax/services/language/translate"
query = ARGV[0]
json_res = open("#{URL}?v=1.0&q=#{URI.encode( query )}&langpair=%7Cja").read
print "\n#{query} => #{JSON.parse( json_res )['responseData']['translatedText']}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment