mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Using the default_locale in locale fallbacks caused problems
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.
This commit is contained in:
@@ -6,19 +6,15 @@ module I18n
|
||||
class FallbackLocaleList < Hash
|
||||
def [](locale)
|
||||
locale = locale.to_sym
|
||||
return [locale] if locale == :en
|
||||
locale_list = [locale]
|
||||
return locale_list if locale == :en
|
||||
|
||||
fallback_locale = LocaleSiteSetting.fallback_locale(locale)
|
||||
site_locale = SiteSetting.default_locale.to_sym
|
||||
|
||||
locale_list =
|
||||
if locale == site_locale || site_locale == :en || fallback_locale == :en
|
||||
[locale, fallback_locale, :en]
|
||||
else
|
||||
site_fallback_locale = LocaleSiteSetting.fallback_locale(site_locale)
|
||||
[locale, fallback_locale, site_locale, site_fallback_locale, :en]
|
||||
end
|
||||
while (fallback_locale = LocaleSiteSetting.fallback_locale(locale))
|
||||
locale_list << fallback_locale
|
||||
locale = fallback_locale
|
||||
end
|
||||
|
||||
locale_list << :en
|
||||
locale_list.uniq.compact
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user