mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 19:02:46 +08:00
FIX: I18n overrides should be multisite aware
This commit is contained in:
parent
2196160549
commit
7f4ca91e06
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue
Block a user