Module: Google::Language

Defined in:
lib/rtranslate/language.rb

Constant Summary collapse

Languages =
{
"lo"=>"LAOTHIAN", 
"ta"=>"TAMIL", 
"eu"=>"BASQUE", 
"iw"=>"HEBREW", 
"my"=>"BURMESE", 
"uk"=>"UKRAINIAN", 
"sk"=>"SLOVAK", 
"ky"=>"KYRGYZ", 
"zh-TW"=>"CHINESE_TRADITIONAL", 
"pa"=>"PUNJABI", 
"sl"=>"SLOVENIAN", 
"ps"=>"PASHTO", 
"ru"=>"RUSSIAN", 
"mk"=>"MACEDONIAN", 
"zh"=>"CHINESE", 
"te"=>"TELUGU", 
"bn"=>"BENGALI", 
"cy"=>"WELSH", 
"hr"=>"CROATIAN", 
"ml"=>"MALAYALAM", 
 "lt"=>"LITHUANIAN", 
 "bo"=>"TIBETAN", 
 "ja"=>"JAPANESE", 
 "tg"=>"TAJIK", 
 "af"=>"AFRIKAANS", 
 "fr"=>"FRENCH", 
 "kk"=>"KAZAKH", 
 "th"=>"THAI", 
 "sq"=>"ALBANIAN", 
 "fa"=>"PERSIAN", 
 "lv"=>"LATVIAN", 
 "vi"=>"VIETNAMESE", 
 "ur"=>"URDU", 
 "az"=>"AZERBAIJANI", 
 "ne"=>"NEPALI", 
 "km"=>"KHMER", 
 "da"=>"DANISH", 
 "sr"=>"SERBIAN", 
 "hu"=>"HUNGARIAN", 
 "mn"=>"MONGOLIAN", 
 "gl"=>"GALICIAN", 
 "kn"=>"KANNADA", 
 "el"=>"GREEK", 
 "ko"=>"KOREAN", 
 "sa"=>"SANSKRIT", 
 "zh-CN"=>"CHINESE_SIMPLIFIED", 
 "gn"=>"GUARANI", 
 "dv"=>"DHIVEHI", 
 "or"=>"ORIYA", 
 "tl"=>"TAGALOG", 
 "chr"=>"CHEROKEE", 
 "en"=>"ENGLISH", 
 "hy"=>"ARMENIAN", 
 "mr"=>"MARATHI", 
 "sv"=>"SWEDISH", 
 "ms"=>"MALAY", 
 "am"=>"AMHARIC", 
 "eo"=>"ESPERANTO", 
 "sd"=>"SINDHI", 
 "pl"=>"POLISH", 
 "de"=>"GERMAN", 
 "be"=>"BELARUSIAN", 
 "nl"=>"DUTCH", 
 "mt"=>"MALTESE", 
 "sw"=>"SWAHILI", 
 "ka"=>"GEORGIAN", 
 "is"=>"ICELANDIC", 
 "ro"=>"ROMANIAN", 
 "ug"=>"UIGHUR", 
 "yi"=>"YIDDISH", 
 "hi"=>"HINDI", 
 "fi"=>"FINNISH", 
 "ku"=>"KURDISH", 
 "pt-PT"=>"PORTUGUESE", 
 "bg"=>"BULGARIAN", 
 "uz"=>"UZBEK", 
 "ga"=>"IRISH", 
 "it"=>"ITALIAN", 
 "tr"=>"TURKISH", 
 "bh"=>"BIHARI", 
 "es"=>"SPANISH", 
 "iu"=>"INUKTITUT", 
 "si"=>"SINHALESE", 
 "no"=>"NORWEGIAN", 
 "ca"=>"CATALAN", 
 "id"=>"INDONESIAN", 
"ar"=>"ARABIC", 
"cs"=>"CZECH", 
"et"=>"ESTONIAN", 
"gu"=>"GUJARATI"}

Class Method Summary collapse

Class Method Details

.abbrev(language) ⇒ Object

get the abbrev of the language



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/rtranslate/language.rb', line 106

def abbrev(language)
  if supported?(language)
    if Languages.key?(language)
      language
    else
      language.upcase!
      Languages.each do |k,v|
        if v == language
          return k
        end
      end
    end
  else
    nil
  end
end

.supported?(language) ⇒ Boolean

judge whether the language is supported by google translate

Returns:

  • (Boolean)


96
97
98
99
100
101
102
# File 'lib/rtranslate/language.rb', line 96

def supported?(language)
  if Languages.key?(language) || Languages.value?(language.upcase)
    true
  else
    false
  end
end