Simplify code involving Globalize.locale

We don't need to set this value. In commit f2ef27d3 I made a mistake
thinking `Globalize.locale` and `I18n.locale` should always be in sync,
but they're actually automatically in sync when `Globalize.locale` is
`nil`.

So the best way to avoid any issues is not to assign `Globalize.locale`,
and use `Globalize.with_locale` where necessary instead.
This commit is contained in:
Javi Martín
2020-06-19 12:41:37 +02:00
committed by taitus
parent dcf0a50b73
commit 002e9239d0
4 changed files with 3 additions and 5 deletions

View File

@@ -18,12 +18,13 @@ class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomiz
next next
else else
text = I18nContent.find_or_create_by!(key: content[:id]) text = I18nContent.find_or_create_by!(key: content[:id])
Globalize.locale = locale Globalize.with_locale(locale) do
text.update!(value: value) text.update!(value: value)
end end
end end
end end
end end
end
redirect_to admin_site_customization_information_texts_path, redirect_to admin_site_customization_information_texts_path,
notice: t("flash.actions.update.translation") notice: t("flash.actions.update.translation")

View File

@@ -55,7 +55,6 @@ class ApplicationController < ActionController::Base
end end
I18n.locale = locale I18n.locale = locale
Globalize.locale = I18n.locale
end end
def set_layout def set_layout

View File

@@ -46,7 +46,6 @@ class Management::BaseController < ActionController::Base
session[:locale] ||= I18n.default_locale session[:locale] ||= I18n.default_locale
I18n.locale = session[:locale] I18n.locale = session[:locale]
Globalize.locale = I18n.locale
end end
def current_budget def current_budget

View File

@@ -26,7 +26,6 @@ RSpec.configure do |config|
config.before do |example| config.before do |example|
I18n.locale = :en I18n.locale = :en
Globalize.locale = nil
Globalize.set_fallbacks_to_all_available_locales Globalize.set_fallbacks_to_all_available_locales
Setting["feature.user.skip_verification"] = nil Setting["feature.user.skip_verification"] = nil
end end