FIX: Application should not crash when selected locale is missing

This commit is contained in:
Gerhard Schlager 2018-01-22 14:44:17 +01:00
parent ce060e2b86
commit 683be5e555
1 changed files with 5 additions and 3 deletions

View File

@ -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