Add i18n helper for controllers to switch language by params

This commit is contained in:
Julius Pabrinkis
2017-06-08 22:33:57 +01:00
committed by Maikel Linke
parent f396d30747
commit 9429695e15
3 changed files with 12 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ class BaseController < ApplicationController
include Spree::Core::ControllerHelpers::Order
include Spree::Core::ControllerHelpers::RespondWith
include I18nHelper
include EnterprisesHelper
include OrderCyclesHelper
@@ -17,9 +18,9 @@ class BaseController < ApplicationController
# include Spree::ProductsHelper so that method is available on the controller
include Spree::ProductsHelper
before_filter :set_locale
before_filter :check_order_cycle_expiry
private
def set_order_cycles

View File

@@ -1,6 +1,9 @@
require 'spree/core/controller_helpers/respond_with_decorator'
Spree::Admin::BaseController.class_eval do
include I18nHelper
before_filter :set_locale
before_filter :warn_invalid_order_cycles
# Warn the user when they have an active order cycle with hubs that are not ready

View File

@@ -0,0 +1,7 @@
module I18nHelper
private
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
end