Class: I18n::Backend::FallbackLocaleList

Inherits:
Hash
  • Object
show all
Defined in:
lib/i18n/backend/fallback_locale_list.rb

Overview

Configure custom fallback order

Instance Method Summary collapse

Instance Method Details

#[](locale) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/i18n/backend/fallback_locale_list.rb', line 7

def [](locale)
  locale = locale.to_sym
  locale_list = [locale]
  return locale_list if locale == :en

  while (fallback_locale = LocaleSiteSetting.fallback_locale(locale))
    locale_list << fallback_locale
    locale = fallback_locale
  end

  locale_list << :en
  locale_list.uniq.compact
end