2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-22 08:42:12 -05:00
|
|
|
module I18n
|
|
|
|
module Backend
|
|
|
|
# Configure custom fallback order
|
|
|
|
class FallbackLocaleList < Hash
|
|
|
|
def [](locale)
|
2019-05-10 19:38:58 -04:00
|
|
|
locale = locale.to_sym
|
2020-05-06 16:57:14 -04:00
|
|
|
locale_list = [locale]
|
|
|
|
return locale_list if locale == :en
|
2019-05-10 19:38:58 -04:00
|
|
|
|
2020-05-06 16:57:14 -04:00
|
|
|
while (fallback_locale = LocaleSiteSetting.fallback_locale(locale))
|
|
|
|
locale_list << fallback_locale
|
|
|
|
locale = fallback_locale
|
|
|
|
end
|
2019-05-10 19:38:58 -04:00
|
|
|
|
2020-05-06 16:57:14 -04:00
|
|
|
locale_list << :en
|
2019-05-10 19:38:58 -04:00
|
|
|
locale_list.uniq.compact
|
2018-01-22 08:42:12 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|