Class: JtcgLocaleDetector::Detector

Inherits:
Object
  • Object
show all
Defined in:
lib/jtcg_locale_detector/detector.rb

Constant Summary collapse

SUPPORTED_LANGUAGES =
%w[
  af am an ar arz as ast av az azb ba bar bcl be bg bh bn bo bpy br bs bxr
  ca cbk ce ceb ckb co cs cv cy da de diq dsb dv dz ee el eml en eo es et
  eu ext fa fi fr frr fy ga gd gl gn gom gu gv he hi hif hr hsb ht hu hy
  ia id ie ilo io is it ja jbo jv ka kk km kn ko krc ku kv kw ky la lb lez
  li lmo lo lrc lt lv mai mg mhr min mk ml mn mr mrj ms mt mwl my myv mzn
  nah nap nds ne new nl nn no oc or os pa pam pfl pl pms pnb ps pt qu rm ro
  ru rue sa sah sc scn sco sd sh si sk sl so sq sr su sv sw szl ta te tg th
  tk tl tr tt tyv ug uk ur uz vec vep vi vls vo wa war wuu xal xmf yi yo
  yue zh zu
].freeze
CHINESE_VARIANTS =
{
  "zh-TW" => "Traditional Chinese (Taiwan)",
  "zh-CN" => "Simplified Chinese (China)",
  "zh-HK" => "Traditional Chinese (Hong Kong)",
  "zh-MO" => "Traditional Chinese (Macau)",
  "zh-SG" => "Simplified Chinese (Singapore)"
}.freeze
DETECTION_MODES =
%w[conversion ratio both].freeze

Class Method Summary collapse

Class Method Details

.chinese_variant?(locale) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/jtcg_locale_detector/detector.rb', line 42

def self.chinese_variant?(locale)
  CHINESE_VARIANTS.key?(locale)
end

.chinese_variantsObject



29
30
31
# File 'lib/jtcg_locale_detector/detector.rb', line 29

def self.chinese_variants
  CHINESE_VARIANTS
end

.detection_modesObject



33
34
35
# File 'lib/jtcg_locale_detector/detector.rb', line 33

def self.detection_modes
  DETECTION_MODES
end

.language_supported?(language_code) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
# File 'lib/jtcg_locale_detector/detector.rb', line 37

def self.language_supported?(language_code)
  base_language = language_code.split("-").first
  SUPPORTED_LANGUAGES.include?(base_language)
end

.supported_languagesObject



25
26
27
# File 'lib/jtcg_locale_detector/detector.rb', line 25

def self.supported_languages
  SUPPORTED_LANGUAGES
end