Skip to content

Instantly share code, notes, and snippets.

@kirs
Created December 11, 2011 19:41
Show Gist options
  • Save kirs/1462329 to your computer and use it in GitHub Desktop.
Save kirs/1462329 to your computer and use it in GitHub Desktop.
Google Translation API: Ruby example
require 'google/api_client'
client = Google::APIClient.new
translate = client.discovered_api('translate', 'v2')
client.authorization.access_token = '123' # dummy
client.key = "my-key-example" # your key from Google API console
response = client.execute(
:api_method => translate.translations.list,
:parameters => {
'format' => 'text',
'source' => 'en',
'target' => 'es',
'q' => 'The quick brown fox jumped over the lazy dog.'
}
)
status, headers, body = response
puts response.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment