class LanguageContext def key :lang end def required? false end 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[key].presence || default end def url_option current unless current == default end end