From 683be5e5550d51c9dfc5d5b118daf37c2a3f5cbe Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Mon, 22 Jan 2018 14:44:17 +0100 Subject: [PATCH] FIX: Application should not crash when selected locale is missing --- app/controllers/application_controller.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 52a94b4d3c4..479082fc6ac 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -237,13 +237,15 @@ class ApplicationController < ActionController::Base def set_locale if !current_user if SiteSetting.set_locale_from_accept_language_header - I18n.locale = locale_from_header + locale = locale_from_header else - I18n.locale = SiteSetting.default_locale + locale = SiteSetting.default_locale end else - I18n.locale = current_user.effective_locale + locale = current_user.effective_locale end + + I18n.locale = I18n.locale_available?(locale) ? locale : :en I18n.ensure_all_loaded! end