FIX: I18n overrides should be multisite aware

This commit is contained in:
Robin Ward 2015-11-18 16:05:53 -05:00
parent 2196160549
commit 7f4ca91e06
2 changed files with 6 additions and 5 deletions

View File

@ -53,7 +53,7 @@ module I18n
return translate_no_cache(key, *args) if args.length > 0
@cache ||= LruRedux::ThreadSafeCache.new(LRU_CACHE_SIZE)
k = "#{key}#{config.locale}#{config.backend.object_id}"
k = "#{key}#{config.locale}#{config.backend.object_id}#{RailsMultisite::ConnectionManagement.current_db}"
@cache.getset(k) do
translate_no_cache(key).freeze

View File

@ -23,15 +23,16 @@ module I18n
def overrides_for(locale)
@overrides ||= {}
return @overrides[locale] if @overrides[locale]
site_overrides = @overrides[RailsMultisite::ConnectionManagement.current_db] ||= {}
@overrides[locale] = {}
return site_overrides[locale] if site_overrides[locale]
locale_overrides = site_overrides[locale] = {}
TranslationOverride.where(locale: locale).pluck(:translation_key, :value).each do |tuple|
@overrides[locale][tuple[0]] = tuple[1]
locale_overrides[tuple[0]] = tuple[1]
end
@overrides[locale]
locale_overrides
end
# In some environments such as migrations we don't want to use overrides.