class Refinery::I18n::Engine

Public Instance Methods

default_url_options() click to toggle source
Calls superclass method
# File lib/refinery/i18n/engine.rb, line 20
def default_url_options
  super.reverse_merge ({ locale: ::I18n.locale })
end
find_or_set_locale() click to toggle source
# File lib/refinery/i18n/engine.rb, line 24
def find_or_set_locale
  ::I18n.locale = ::Refinery::I18n.current_frontend_locale

  if ::Refinery::I18n.has_locale?(locale = params[:locale].try(:to_sym))
    ::I18n.locale = locale
  elsif locale.present? && locale != ::Refinery::I18n.default_frontend_locale
    ::I18n.locale = ::Refinery::I18n.default_frontend_locale
    redirect_to(params.permit(:locale).merge(locale: ::I18n.locale),
                notice: "The locale '#{locale}' is not supported.") and return
  else
    ::I18n.locale = ::Refinery::I18n.default_frontend_locale
  end
  Mobility.locale = ::I18n.locale
end
globalize!() click to toggle source
# File lib/refinery/i18n/engine.rb, line 53
def globalize!
  if ::Refinery::I18n.frontend_locales.any?
    if params[:switch_locale]
      Mobility.locale = params[:switch_locale].to_sym
    elsif ::I18n.locale != ::Refinery::I18n.default_frontend_locale
      Mobility.locale = ::Refinery::I18n.default_frontend_locale
    else
      Mobility.locale = ::I18n.locale
    end
  end
end