Merge pull request #10258 from demarches-simplifiees/fix_strange_locale
tech: verifie que la locale est disponible
This commit is contained in:
commit
3f54d46f19
1 changed files with 3 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue