mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-02 17:57:36 +08:00
When Translation Overrides are changed, a message is sent on the `/i18n-flush` channel to ensure all running unicorns flush their caches. This message is not received in a database-specific context, so running `ExtraLocalesController.clear_cache!` was only affecting the default site in a multisite cluster. This commit updates it to flush caches for all sites.
22 lines
720 B
Ruby
22 lines
720 B
Ruby
# frozen_string_literal: true
|
|
|
|
# order: after 02-freedom_patches.rb
|
|
|
|
require "i18n/backend/discourse_i18n"
|
|
require "i18n/backend/fallback_locale_list"
|
|
|
|
# Requires the `translate_accelerator.rb` freedom patch to be loaded
|
|
Rails.application.reloader.to_prepare do
|
|
I18n.backend = I18n::Backend::DiscourseI18n.new
|
|
I18n.fallbacks = I18n::Backend::FallbackLocaleList.new
|
|
I18n.config.missing_interpolation_argument_handler = proc { throw(:exception) }
|
|
I18n.reload!
|
|
I18n.init_accelerator!(overrides_enabled: ENV["DISABLE_TRANSLATION_OVERRIDES"] != "1")
|
|
|
|
unless Rails.env.test?
|
|
MessageBus.subscribe("/i18n-flush") do
|
|
I18n.reload!
|
|
ExtraLocalesController.clear_cache!(all_sites: true)
|
|
end
|
|
end
|
|
end
|