Merge pull request #10258 from demarches-simplifiees/fix_strange_locale

tech: verifie que la locale est disponible
This commit is contained in:
LeSim 2024-04-03 07:11:12 +00:00 committed by GitHub
commit 3f54d46f19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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)