Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simple Ruby Client for Google Translator API
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.DS_Store
.gitignore
Gemfile
LICENSE
README.md
Rakefile
google_translate.gemspec

README.md

GoogleTranslate - Simple Ruby Client for Google Translate API

http://code.google.com/apis/language/translate/overview.html

Installation

Add this line to your application's Gemfile:

gem 'google_translate'

And then execute:

$ bundle

Or install it yourself as:

$ gem install google_translate

Usage

from_language = 'es'
to_language = 'en'
@gt = Google::Translate.new(from_language, to_language, {:api_key => 'YOUR_API_KEY'})
puts @gt.translate('perro')

By default, the translator caches term translations in order to avoid unnecessary requests. This can be globally disabled passing:

:cache => false

in the options hash.

You can also skip the caching only for certain translation requests by passing

:cache => false

to the translate method.

@gt.translate('A longer sentence that won't likely be repeated', { :cache => false })

See Google Translate API v2 for details about parameters, including supported language codes.

Note: Google::Translator can still be used instead of Google::Translate for backwards compatibility

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

Copyright © 2011 Christian Hein, released under the MIT license

Something went wrong with that request. Please try again.