aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 5f18be2e5..0d8c83d6c 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -42,7 +42,11 @@ class ApplicationController < ActionController::Base
end
def set_gettext_locale
- requested_locale = params[:locale] || session[:locale] || cookies[:locale] || request.env['HTTP_ACCEPT_LANGUAGE']
+ if MySociety::Config.get('USE_DEFAULT_BROWSER_LANGUAGE', true)
+ requested_locale = params[:locale] || session[:locale] || cookies[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'] || I18n.default_locale
+ else
+ requested_locale = params[:locale] || session[:locale] || cookies[:locale] || I18n.default_locale
+ end
session[:locale] = FastGettext.set_locale(requested_locale)
end
@@ -221,7 +225,11 @@ class ApplicationController < ActionController::Base
if session[:user_id].nil?
return nil
else
- return User.find(session[:user_id])
+ begin
+ return User.find(session[:user_id])
+ rescue ActiveRecord::RecordNotFound
+ return nil
+ end
end
end