First, the configuration is now stored on the Fiber:
Fiber[:i18n_config]
The new implementation detects when a Fiber inherits a configuration owned by another Fiber:
if current.respond_to?(:owned_by?) && !current.owned_by?(Fiber.current)
current = current.dup
Fiber[:i18n_config] = current
end
The problem lies in I18n::Config#initialize_copy:
def initialize_copy(other)
@owner = Fiber.current
end
It changes the owner of the copied configuration, but it does not clear the copied @locale; i.e., a child Fiber inherits the parent’s explicit @locale.
So if the parent Fiber currently has:
I18n.locale == :zh_CN
a child Fiber can inherit a copied configuration that still contains:
@locale == :zh_CN
even though that child Fiber now represents a different request that should resolve to English.
This causes a problem in Discourse when the user is using a display language different from the default language. For example, if Chinese is the site’s default language and English is the display language, pages may accidentally display in Chinese, or as a combination of English and Chinese.
A commit has been raised to roll back the version update and some specs have been added. Perhaps pausing the update until upstream fixes the issue would be a great idea.