I18n: Automatically choose locale through HTTP header

This commit is contained in:
Sebastian Serth
2022-12-20 10:26:32 +01:00
parent 78f87fef4b
commit 7cd61acbce
3 changed files with 4 additions and 1 deletions

View File

@ -122,7 +122,7 @@ class ApplicationController < ActionController::Base
def switch_locale(&)
session[:locale] = sanitize_locale(params[:custom_locale] || params[:locale] || session[:locale])
locale = session[:locale] || I18n.default_locale
locale = session[:locale] || http_accept_language.compatible_language_from(I18n.available_locales) || I18n.default_locale
Sentry.set_extras(locale:)
I18n.with_locale(locale, &)
end