module RouteTranslator::Controller

Private Instance Methods

set_locale_from_url() { || ... } click to toggle source
# File lib/route_translator/extensions/action_controller.rb, line 11
def set_locale_from_url
  locale_from_url = RouteTranslator.locale_from_params(params) || RouteTranslator::Host.locale_from_host(request.host)
  if locale_from_url
    old_locale  = I18n.locale
    I18n.locale = locale_from_url
  end

  yield
ensure
  I18n.locale = old_locale if locale_from_url
end