diff --git a/lib/freedom_patches/translate_accelerator.rb b/lib/freedom_patches/translate_accelerator.rb index 77678081499..604b85d04cc 100644 --- a/lib/freedom_patches/translate_accelerator.rb +++ b/lib/freedom_patches/translate_accelerator.rb @@ -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 diff --git a/lib/i18n/backend/discourse_i18n.rb b/lib/i18n/backend/discourse_i18n.rb index c901601bcc7..8b18e6f4082 100644 --- a/lib/i18n/backend/discourse_i18n.rb +++ b/lib/i18n/backend/discourse_i18n.rb @@ -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.