Plugin: Simple Ruby Client for Google Translator API
Ruby
Pull request Compare This branch is 1 commit ahead, 12 commits behind chrishein:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
LICENSE
README.rdoc
google_translate-0.0.1.gem
google_translate.gemspec

README.rdoc

Google Translate - Simple Ruby Client for Google Translate API

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

Usage

from_language = 'es'
to_language = 'en'
@gt = Google::Translator.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 })

Below is a list of language codes that can be used for translation

“af”-Afrikaans “sq”-Albanian “ar”-Arabic “hy”-Armenian ALPHA “az”-Azerbaijani ALPHA “eu”-Basque ALPHA “be”-Belarusian “bg”-Bulgarian “ca”-Catalan “zh-CN”-Chinese “hr”-Croatian “cs”-Czech “da”-Danish “nl”-Dutch “en”-English “et”-Estonian “tl”-Filipino “fi”-Finnish “fr”-French “gl”-Galician “ka”-Georgian ALPHA “de”-German “el”-Greek “ht”-Haitian Creole ALPHA “iw”-Hebrew “hi”-Hindi “hu”-Hungarian “is”-Icelandic “id”-Indonesian “ga”-Irish “it”-Italian “ja”-Japanese “ko”-Korean “lv”-Latvian “lt”-Lithuanian “mk”-Macedonian “ms”-Malay “mt”-Maltese “no”-Norwegian “fa”-Persian “pl”-Polish “pt”-Portuguese “ro”-Romanian “ru”-Russian “sr”-Serbian “sk”-Slovak “sl”-Slovenian “es”-Spanish “sw”-Swahili “sv”-Swedish “th”-Thai “tr”-Turkish “uk”-Ukrainian “ur”-Urdu ALPHA “vi”-Vietnamese “cy”-Welsh “yi”-Yiddish

License

Copyright © 2011 Christian Hein, released under the MIT license