fix: avoid buggy locale from user

This commit is contained in:
simon lehericey 2024-04-02 21:53:56 +02:00
parent b245d9b063
commit fc8d5adf2f
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5

View file

@ -385,12 +385,14 @@ class ApplicationController < ActionController::Base
end
def switch_locale(&action)
locale = extract_locale_from_query_params ||
unchecked_locale = extract_locale_from_query_params ||
extract_locale_from_cookie ||
extract_locale_from_user ||
extract_locale_from_accept_language_header ||
I18n.default_locale
locale = unchecked_locale.to_sym.in?(I18n.available_locales) ? unchecked_locale : I18n.default_locale
gon.locale = locale
I18n.with_locale(locale, &action)