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