Skip to content

Commit

Permalink
fixes #74
Browse files Browse the repository at this point in the history
  • Loading branch information
fosterfarrell9 committed Sep 16, 2020
1 parent 3de077b commit 67586f7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,8 @@ def store_user_location!
end

def set_locale
if params[:locale].in?(I18n.available_locales.map(&:to_s))
locale_param = params[:locale]
end
I18n.locale = current_user.try(:locale) || locale_param ||
cookies[:locale] || I18n.default_locale
cookie_param || I18n.default_locale
unless user_signed_in?
cookies[:locale] = I18n.locale
end
Expand All @@ -98,4 +95,18 @@ def store_interaction
request.referrer,
study_participant)
end

def locale_param
return unless params[:locale].in?(available_locales)
params[:locale]
end

def cookie_param
return unless cookies[:locale].in?(available_locales)
cookies[:locale]
end

def available_locales
I18n.available_locales.map(&:to_s)
end
end

0 comments on commit 67586f7

Please sign in to comment.