Skip to content

Commit

Permalink
Fix invalid locales breaking language selection
Browse files Browse the repository at this point in the history
  • Loading branch information
BGMP committed Mar 20, 2024
1 parent 21e3d75 commit d2e71cd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -8,8 +8,17 @@ class ApplicationController < ActionController::Base
def set_locale
if user_signed_in?
I18n.locale = current_user.locale
return
end

# If user is guest, we try to determine their locale ...

locale = params[:locale] || locale_from_header

if SYS::LOCALES_MAP.values.include?(locale.to_sym)
I18n.locale = locale
else
I18n.locale = params[:locale] || locale_from_header || I18n.default_locale
I18n.locale = I18n.default_locale
end
end

Expand Down

0 comments on commit d2e71cd

Please sign in to comment.