Class: GoogleAjax::Language
- Inherits:
-
Object
- Object
- GoogleAjax::Language
- Defined in:
- lib/google_ajax/language.rb
Defined Under Namespace
Classes: Language, Translation
Constant Summary collapse
- LANGUAGE_VERSION =
1.0
- LANGUAGES =
{ 'ARABIC' => 'ar', 'BULGARIAN' => 'bg', 'CATALAN' => 'ca', 'CHINESE' => 'zh', 'CHINESE_SIMPLIFIED' => 'zh-CN', 'CHINESE_TRADITIONAL' => 'zh-TW', 'CROATIAN' => 'hr', 'CZECH' => 'cs', 'DANISH' => 'da', 'DUTCH'=> 'nl', 'ENGLISH' => 'en', 'ESTONIAN' => 'et', 'FILIPINO' => 'tl', 'FINISH' => 'fi', 'FRENCH' => 'fr', 'GERMAN' => 'de', 'GREK' => 'el', 'HEBREW' => 'iw', 'HINDI' => 'hi', 'HUNGARIAN' => 'hu', 'INDONESIAN' => 'id', 'ITALIAN' => 'it', 'JAPANESE' => 'ja', 'KOREAN' => 'ko', 'LATVIAN' => 'lv', 'LITHUANIAN' => 'lt', 'NORWEGIAN' => 'no', 'PERSIAN' => 'fa', 'POLISH' => 'pl', 'PORTUGUESE' => 'pt-PT', 'ROMANIAN' => 'ro', 'RUSIAN' => 'ru', 'SERBIAN' => 'sr', 'SLOVAK' => 'sk', 'SLOVENIAN' => 'sl', 'SPANISH' => 'es', 'SWEDISH' => 'sv', 'THAI' => 'th', 'TURKISH' => 'tr', 'UKRAINIAN' => 'uk', 'VIETNAMESE' => 'vi', 'UNKNOWN' => '' }
Class Method Summary collapse
-
.detect(query, args = {}) ⇒ Object
will return the language code that describes the language of the given text.
- .get(method, query, args = {}) ⇒ Object
-
.translate(query, source, destination, args = {}) ⇒ Object
will return translated text for the given text supplied, matching the destination language.
Class Method Details
.detect(query, args = {}) ⇒ Object
will return the language code that describes the language of the given text
10 11 12 |
# File 'lib/google_ajax/language.rb', line 10 def self.detect(query, args = {}) self.get(:detect, query) end |
.get(method, query, args = {}) ⇒ Object
4 5 6 7 |
# File 'lib/google_ajax/language.rb', line 4 def self.get(method, query, args = {}) args = { :v => LANGUAGE_VERSION }.merge!(args) GoogleAjax::get(:language, method, query, args) end |
.translate(query, source, destination, args = {}) ⇒ Object
will return translated text for the given text supplied, matching the destination language.
15 16 17 18 |
# File 'lib/google_ajax/language.rb', line 15 def self.translate(query, source, destination, args = {}) args = { :langpair => "#{source}%7C#{destination}"}.merge!(args) self.get(:translate, query, args) end |