FIX: Translation overrides were not cached by locale properly.

This commit is contained in:
Guo Xiang Tan
2017-07-07 12:28:00 +09:00
parent 198f308f7b
commit a4399c2eab
2 changed files with 22 additions and 3 deletions

View File

@@ -104,10 +104,9 @@ module I18n
site = RailsMultisite::ConnectionManagement.current_db
by_site = @overrides_by_site[site]
by_site ||= {}
if by_site.nil? || !by_site.has_key?(locale)
by_site = @overrides_by_site[site] = {}
if !by_site.has_key?(locale)
# Load overrides
translations_overrides = TranslationOverride.where(locale: locale).pluck(:translation_key, :value, :compiled_js)
@@ -119,6 +118,8 @@ module I18n
by_locale[tuple[0]] = tuple[2] || tuple[1]
end
end
@overrides_by_site[site] = by_site
end
by_site[locale].with_indifferent_access