module Spree::Core::ControllerHelpers::Locale

Public Instance Methods

available_locales() click to toggle source
# File lib/spree/core/controller_helpers/locale.rb, line 46
def available_locales
  Spree::Store.available_locales
end
current_locale() click to toggle source
# File lib/spree/core/controller_helpers/locale.rb, line 22
def current_locale
  @current_locale ||= if params[:locale].present? && supported_locale?(params[:locale])
                        params[:locale]
                      elsif respond_to?(:config_locale, true) && config_locale.present?
                        config_locale
                      else
                        current_store&.default_locale || Rails.application.config.i18n.default_locale || I18n.default_locale
                      end
end
locale_param() click to toggle source
# File lib/spree/core/controller_helpers/locale.rb, line 50
def locale_param
  return if I18n.locale.to_s == current_store.default_locale || current_store.default_locale.nil?

  I18n.locale.to_s
end
set_locale() click to toggle source
# File lib/spree/core/controller_helpers/locale.rb, line 18
def set_locale
  I18n.locale = current_locale
end
supported_locale?(locale_code) click to toggle source
# File lib/spree/core/controller_helpers/locale.rb, line 36
def supported_locale?(locale_code)
  return false if supported_locales.nil?

  supported_locales.include?(locale_code&.to_s)
end
supported_locales() click to toggle source
# File lib/spree/core/controller_helpers/locale.rb, line 32
def supported_locales
  @supported_locales ||= current_store&.supported_locales_list
end
supported_locales_for_all_stores() click to toggle source
# File lib/spree/core/controller_helpers/locale.rb, line 42
def supported_locales_for_all_stores
  @supported_locales_for_all_stores ||= Spree.available_locales
end