Sha256: 34342b26a580ca926e1ac88e0a169920ba616e50b619ce817078d2abc0e5feaa

Contents?: true

Size: 353 Bytes

Versions: 1

Compression:

Stored size: 353 Bytes

Contents

class LocaleContext
  def constraints
    Regexp.new(I18n.available_locales.join('|'))
  end

  def default
    I18n.default_locale
  end

  def current
    I18n.locale
  end

  def apply(controller, value)
    I18n.locale = value || controller.params[:locale].presence || default
  end

  def url_option
    current unless current == default
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contexts-2.0.0 spec/dummy/app/contexts/locale_context.rb