mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 19:45:23 +08:00
ec2f3169ff
Locale files get precompiled after deployment and they contained translations from the `default_locale`. That's especially bad in multisites, because the initial `default_locale` is `en_US`. Sites where the `default_locale` isn't `en_US` could see missing translations. The same thing could happen when users are allowed to chose a different locale. This change simplifies the logic by not using the `default_locale` in the locale chain. It always falls back to `en` in case of missing translations.
23 lines
515 B
Ruby
23 lines
515 B
Ruby
# frozen_string_literal: true
|
|
|
|
module I18n
|
|
module Backend
|
|
# Configure custom fallback order
|
|
class FallbackLocaleList < Hash
|
|
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
|
|
end
|
|
end
|
|
end
|