FIX: Fallback locale was not available for extra translations

Translations from fallback locales were not sent to the client
for admin_js and wizard_js.
This commit is contained in:
Gerhard Schlager
2019-05-23 21:23:31 +02:00
parent 0e24cb0f78
commit c1e9a70d59
8 changed files with 135 additions and 66 deletions

View File

@ -104,28 +104,32 @@ module JsLocaleHelper
end
end
def self.clear_cache!
@loaded_translations = nil
@plugin_translations = nil
@loaded_merges = nil
end
def self.translations_for(locale_str)
if Rails.env.development?
@loaded_translations = nil
@plugin_translations = nil
@loaded_merges = nil
end
clear_cache! if Rails.env.development?
locale_sym = locale_str.to_sym
I18n.with_locale(locale_sym) do
translations = I18n.with_locale(locale_sym) do
if locale_sym == :en
load_translations(locale_sym)
else
load_translations_merged(*I18n.fallbacks[locale_sym])
end
end
Marshal.load(Marshal.dump(translations))
end
def self.output_locale(locale)
locale_str = locale.to_s
fallback_locale_str = LocaleSiteSetting.fallback_locale(locale_str)&.to_s
translations = Marshal.load(Marshal.dump(translations_for(locale_str)))
translations = translations_for(locale_str)
message_formats = remove_message_formats!(translations, locale)
mf_locale, mf_filename = find_message_format_locale([locale_str], fallback_to_english: true)