Ensure we load locale from localizer

Before this commit, if you requested a locale before you had asked
for a translation, you might have gotten the wrong locale.

This is because loading a translation forces the eager fetching of locale
configuration that is set earlier in the application controller lifecycle.
This commit fixes that by wrapping the locale accessor with a call
that also forces eager loading of locale configuration first.

refs FOO-3163

Change-Id: Icfa7f26dc8ca2579163d6c9cb614ab27579f33c0
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/303252
QA-Review: Sean Scally <sean.scally@instructure.com>
Product-Review: Sean Scally <sean.scally@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
This commit is contained in:
Sean Scally 2022-10-13 14:38:01 -07:00
parent b569e750d7
commit eb2f914481
1 changed files with 5 additions and 0 deletions

View File

@ -286,6 +286,11 @@ I18n.send(:extend, Module.new do
end
alias_method :t, :translate
def locale
set_locale_with_localizer
super
end
def bigeasy_locale
backend.send(:lookup, locale.to_s, "bigeasy_locale") || locale.to_s.tr("-", "_")
end