Module: GScraper::Languages
- Defined in:
- lib/gscraper/languages.rb
Overview
Constant Summary collapse
- NAMES =
The list of language names
%w[ af ar be bg ca cs da de el en eo es et fa fi fr hi hr hu hy id is it iw ja ko lt lv nl no pl pt ro ru sk sl sr sv sw th tl tr uk vi zh-CN zh-TW ]
Class Method Summary collapse
-
.find(locale) ⇒ String
Looks up the language for the given locale.
-
.native ⇒ String
Determines the native language.
Class Method Details
.find(locale) ⇒ String
Looks up the language for the given locale.
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/gscraper/languages.rb', line 87 def Languages.find(locale) if locale =~ /^zh_CN/ 'zh-CN' elsif locale =~ /^zh_TW/ 'zh-TW' else if (match = locale.match(/^([^_@]+)([_@].+)?$/)) match[1] if (match[1] && NAMES.include?(match[1])) end end end |