Sha256: 491d5be4b37cae75ed270d4870c530a6b70a600a2b234f13be6472f91b6ea191
Contents?: true
Size: 1021 Bytes
Versions: 1
Compression:
Stored size: 1021 Bytes
Contents
module SolidusI18n # The fact this logic is in a single module also helps to apply a custom # locale on the spree/api context since api base controller inherits from # MetalController instead of Spree::BaseController module ControllerLocaleHelper extend ActiveSupport::Concern included do prepend_before_action :set_user_language private # Overrides the Spree::Core::ControllerHelpers::Common logic so that only # supported locales defined by SolidusI18n::Config.supported_locales can # actually be set def set_user_language # params[:locale] can be added by routing-filter gem I18n.locale = \ if params[:locale] && Config.available_locales.include?(params[:locale].to_sym) params[:locale] elsif respond_to?(:config_locale, true) && !config_locale.blank? config_locale else Rails.application.config.i18n.default_locale || I18n.default_locale end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_i18n-1.2.0 | lib/solidus_i18n/controller_locale_helper.rb |