Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Davila <rdavila84@gmail.com>2017-05-03 07:36:36 +0300
committerRuben Davila <rdavila84@gmail.com>2017-05-03 07:36:36 +0300
commit6d5364cfb0e39f49afac9b465f37bd19185c3755 (patch)
tree1bdb7ff4e44307f561efcda47eef7f0f775258fe /app/controllers/application_controller.rb
parentbbfbcebdf69261bac6aa142f430719955e8e86b9 (diff)
First round of updates from the code review.
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index f2997d0b0c4..24017e8ea40 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -21,6 +21,8 @@ class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
before_action :require_email, unless: :devise_controller?
+ around_action :set_locale
+
protect_from_forgery with: :exception
helper_method :can?, :current_application_settings
@@ -271,9 +273,14 @@ class ApplicationController < ActionController::Base
end
def set_locale
- requested_locale = current_user&.preferred_language || request.env['HTTP_ACCEPT_LANGUAGE'] || I18n.default_locale
- locale = FastGettext.set_locale(requested_locale)
-
- I18n.locale = locale
+ begin
+ requested_locale = current_user&.preferred_language || I18n.default_locale
+ locale = FastGettext.set_locale(requested_locale)
+ I18n.locale = locale
+
+ yield
+ ensure
+ I18n.locale = I18n.default_locale
+ end
end
end