app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery with: :reset_session
before_action :set_locale
def default_url_options(*)
{ locale: I18n.locale == I18n.default_locale ? nil : I18n.locale }
end
private
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
end