easy_translate 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/easy_translate.rb +17 -29
- data/lib/easy_translate/translator.rb +1 -0
- data/lib/easy_translate/version.rb +1 -1
- metadata +2 -1
data/lib/easy_translate.rb
CHANGED
@@ -13,34 +13,22 @@ module EasyTranslate
|
|
13
13
|
API_TRANSLATE_PATH = '/ajax/services/language/translate'
|
14
14
|
API_DETECT_PATH = '/ajax/services/language/detect'
|
15
15
|
API_VERSION = '1.0'
|
16
|
-
|
17
|
-
LANGUAGES = { '
|
18
|
-
'
|
19
|
-
'
|
20
|
-
'
|
21
|
-
'
|
22
|
-
'
|
23
|
-
'
|
24
|
-
'
|
25
|
-
'
|
26
|
-
'
|
27
|
-
'
|
28
|
-
'
|
29
|
-
'
|
30
|
-
'
|
31
|
-
'
|
32
|
-
'
|
33
|
-
'eu' => 'basque', 'dv' => 'dhivehi', 'sl' => 'slovenian',
|
34
|
-
'pl' => 'polish', 'el' => 'greek', 'ku' => 'kurdish', 'de' => 'german',
|
35
|
-
'iw' => 'hebrew', 'sd' => 'sindhi', 'et' => 'estonian', 'gn' => 'guarani',
|
36
|
-
'is' => 'icelandic', 'bn' => 'bengali', 'tl' => 'filipino',
|
37
|
-
'bo' => 'tibetan', 'es' => 'spanish', 'fr' => 'french',
|
38
|
-
'hy' => 'armenian', 'bg' => 'bulgarian', 'lt' => 'lithuanian',
|
39
|
-
'mn' => 'mongolian', 'az' => 'azerbaijani', 'yi' => 'yiddish',
|
40
|
-
'ur' => 'urdu', 'en' => 'english', 'pt-pt' => 'portuguese',
|
41
|
-
'vi' => 'vietnamese', 'ml' => 'malayalam', 'ar' => 'arabic',
|
42
|
-
'bh' => 'bihari', 'iu' => 'inuktitut', 'my' => 'burmese',
|
43
|
-
'hu' => 'hungarian', 'ko' => 'korean', 'tg' => 'tajik', 'cs' => 'czech',
|
44
|
-
'hi' => 'hindi', 'hr' => 'croatian' }
|
16
|
+
|
17
|
+
LANGUAGES = { 'af' => 'afrikaans', 'sq' => 'albanian', 'ar' => 'arabic',
|
18
|
+
'hy' => 'armenian', 'az' => 'azerbaijani', 'eu' => 'basque', 'be' => 'belarusian',
|
19
|
+
'bg' => 'bulgarian', 'ca' => 'catalan', 'zh-CN' => 'chinese_simplified',
|
20
|
+
'zh-TW' => 'chinese_traditional', 'hr' => 'croatian', 'cs' => 'czech',
|
21
|
+
'da' => 'danish', 'nl' => 'dutch', 'en' => 'english', 'et' => 'estonian',
|
22
|
+
'tl' => 'filipino', 'fi' => 'finnish', 'fr' => 'french', 'gl' => 'galician',
|
23
|
+
'ka' => 'georgian', 'de' => 'german', 'el' => 'greek', 'ht' => 'haitian_creole',
|
24
|
+
'iw' => 'hebrew', 'hi' => 'hindi', 'hu' => 'hungarian', 'is' => 'icelandic',
|
25
|
+
'id' => 'indonesian', 'ga' => 'irish', 'it' => 'italian', 'ja' => 'japanese',
|
26
|
+
'ko' => 'korean', 'lv' => 'latvian', 'lt' => 'lithuanian', 'mk' => 'macedonian',
|
27
|
+
'ms' => 'malay', 'mt' => 'maltese', 'no' => 'norwegian', 'fa' => 'persian',
|
28
|
+
'pl' => 'polish', 'pt' => 'portuguese', 'ro' => 'romanian', 'ru' => 'russian',
|
29
|
+
'sr' => 'serbian', 'sk' => 'slovak', 'sl' => 'slovenian', 'es' => 'spanish',
|
30
|
+
'sw' => 'swahili', 'sv' => 'swedish', 'th' => 'thai', 'tr' => 'turkish',
|
31
|
+
'uk' => 'ukrainian', 'ur' => 'urdu', 'vi' => 'vietnamese', 'cy' => 'welsh',
|
32
|
+
'yi' => 'yiddish' }
|
45
33
|
|
46
34
|
end
|
@@ -141,6 +141,7 @@ module EasyTranslate
|
|
141
141
|
# a function used to get the lang code of any input.
|
142
142
|
# can take -- :english, 'english', :en, 'en'
|
143
143
|
def self.get_language(lang)
|
144
|
+
return unless lang
|
144
145
|
lang = lang.to_s
|
145
146
|
lang = EasyTranslate::LANGUAGES.include?(lang) ? lang : EasyTranslate::LANGUAGES.index(lang)
|
146
147
|
raise ArgumentError.new('please supply a valid language') unless lang
|