# frozen_string_literal: true class ApplicationController < ActionController::Base around_action :switch_locale def switch_locale(&action) locale = extract_locale I18n.with_locale(locale, &action) end def new_session_path(_scope) new_user_session_path end def extract_locale if params[:locale] I18n.locale_available?(params[:locale]) ? params[:locale] : I18n.default_locale elsif request.env['HTTP_ACCEPT_LANGUAGE'] I18n.locale_available?(request.env['HTTP_ACCEPT_LANGUAGE']) ? request.env['HTTP_ACCEPT_LANGUAGE'] : I18n.default_locale else I18n.default_locale end end def default_url_options { locale: I18n.locale } end end