fix: avoid buggy locale from user
This commit is contained in:
parent
b245d9b063
commit
fc8d5adf2f
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