Class: Spree::LocaleController
Constant Summary
collapse
- REDIRECT_TO_ROOT =
/\/(pages)\//.freeze
Instance Method Summary
collapse
#account_link, #api_tokens, #cart_link, #ensure_cart
Instance Method Details
#index ⇒ Object
5
6
7
|
# File 'app/controllers/spree/locale_controller.rb', line 5
def index
render :index, layout: false
end
|
#set ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/spree/locale_controller.rb', line 9
def set
new_locale = (params[:switch_to_locale] || params[:locale]).to_s
if new_locale.present? && supported_locale?(new_locale)
if try_spree_current_user && try_spree_current_user.selected_locale != new_locale
try_spree_current_user.update!(selected_locale: new_locale)
end
if should_build_new_url?
redirect_to BuildLocalizedRedirectUrl.call(
url: request.env['HTTP_REFERER'],
locale: new_locale,
default_locale: current_store.default_locale
).value
else
redirect_to root_path(locale: new_locale)
end
else
redirect_to root_path
end
end
|