From d2e71cd16d6ee4ed5bfd1bab3bbc8d5ac25bdf33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Benavente?= Date: Tue, 19 Mar 2024 22:25:59 -0300 Subject: [PATCH] Fix invalid locales breaking language selection --- app/controllers/application_controller.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a9532cab..a8d8e330 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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