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
|
|
|
|
return [locale] if locale == :en
|
|
|
|
|
2018-01-25 06:09:18 -05:00
|
|
|
fallback_locale = LocaleSiteSetting.fallback_locale(locale)
|
2019-05-10 19:38:58 -04:00
|
|
|
site_locale = SiteSetting.default_locale.to_sym
|
|
|
|
|
|
|
|
locale_list =
|
2019-06-07 15:53:01 -04:00
|
|
|
if locale == site_locale || site_locale == :en || fallback_locale == :en
|
2019-05-10 19:38:58 -04:00
|
|
|
[locale, fallback_locale, :en]
|
|
|
|
else
|
|
|
|
site_fallback_locale = LocaleSiteSetting.fallback_locale(site_locale)
|
|
|
|
[locale, fallback_locale, site_locale, site_fallback_locale, :en]
|
|
|
|
end
|
|
|
|
|
|
|
|
locale_list.uniq.compact
|
2018-01-22 08:42:12 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|