Class: Spree::Admin::LocaleController
Instance Method Summary
collapse
#set_user_language_locale_key
Instance Method Details
#set ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/spree/admin/locale_controller.rb', line 8
def set
requested_locale = params[:switch_to_locale].to_s.presence
if locale_is_available?(requested_locale)
I18n.locale = requested_locale
session[set_user_language_locale_key] = requested_locale
respond_to do |format|
format.json { render json: { locale: requested_locale, location: spree.admin_url } }
format.html { redirect_back_or_to spree.admin_url, notice: t('spree.locale_changed') }
end
else
respond_to do |format|
format.json { render json: { locale: I18n.locale }, status: 404 }
format.html { redirect_back_or_to spree.admin_url, error: t('spree.error') }
end
end
end
|