Class: Spree::LocaleController

Inherits:
StoreController show all
Defined in:
app/controllers/spree/locale_controller.rb

Instance Method Summary collapse

Methods inherited from StoreController

#account_link, #api_tokens, #cart_link, #ensure_cart, #forbidden, #unauthorized

Instance Method Details

#setObject



3
4
5
6
7
8
9
10
11
12
# File 'app/controllers/spree/locale_controller.rb', line 3

def set
  session['user_return_to'] = request.referer if request.referer&.starts_with?('http://' + request.host)
  if params[:locale] && I18n.available_locales.map(&:to_s).include?(params[:locale])
    session[:locale] = I18n.locale = params[:locale]
    flash.notice = Spree.t(:locale_changed)
  else
    flash[:error] = Spree.t(:locale_not_changed)
  end
  redirect_back_or_default(spree.root_path)
end