Skip to content

Commit

Permalink
Use a string comparsion for locale parameters
Browse files Browse the repository at this point in the history
Conflicts:
	core/lib/spree/core/controller_helpers.rb
  • Loading branch information
radar authored and huoxito committed Feb 6, 2013
1 parent 137d58b commit 700ba4f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/app/controllers/spree/locale_controller.rb
Expand Up @@ -4,8 +4,8 @@ def set
if request.referer && request.referer.starts_with?('http://' + request.host)
session['user_return_to'] = request.referer
end
if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym)
session[:locale] = I18n.locale = params[:locale].to_sym
if params[:locale] && I18n.available_locales.map(&:to_s).include?(params[:locale])
session[:locale] = I18n.locale = params[:locale]
flash.notice = t(:locale_changed)
else
flash[:error] = t(:locale_not_changed)
Expand Down
6 changes: 2 additions & 4 deletions core/lib/spree/core/controller_helpers.rb
Expand Up @@ -162,10 +162,8 @@ def redirect_back_or_default(default)
def set_user_language
locale = session[:locale]
locale ||= Rails.application.config.i18n.default_locale
if locale.blank? || !I18n.available_locales.include?(locale.to_sym)
locale ||= I18n.default_locale
end
I18n.locale = locale.to_sym
locale ||= I18n.default_locale unless I18n.available_locales.map(&:to_s).include?(locale)
I18n.locale = locale
end

# Returns which layout to render.
Expand Down

0 comments on commit 700ba4f

Please sign in to comment.