mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 23:54:16 +08:00
374ab82dd6
The logster initializer tries to adds RailsMultisite::Formatter to the STDOUT logger. In production, the lograge initializer then removes the RailsMultisite:Formatter because the JSON log will include the database.e10a74694a
used `Rails.application.reloader.to_prepare` to defer running the 100-logster initializer, which meant it ran **after** 101-lograge. This meant that we were writing JSON logs with a non-json text prefix. The `to_prepare` was added because our freedom-patches are now deferred using `to_prepare`, and some initializers were relying on the freedom patches. However, following1533cbb38b
, we decided to load the RailsMultisite freedom patch without `to_prepare`. Therefore, `005-site_settings` and `100-logster` no longer need to use `to_prepare`. Removing it means that these initializers are back to running in sequential order, and the logging issue will be resolved. The only remaining initializer which depends on freedom patches is `100-i18n`. I've added a comment to explain why.
23 lines
703 B
Ruby
23 lines
703 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!
|
|
end
|
|
end
|
|
end
|