maestrano/mno-enterprise

View on GitHub
core/lib/mno_enterprise/concerns/controllers/i18n.rb

Summary

Maintainability
A
0 mins
Test Coverage
# Add a before_filter to set the locale based on the params or the default locale
module MnoEnterprise::Concerns::Controllers::I18n
  extend ActiveSupport::Concern

  included do
    before_action :set_locale
  end

  def set_locale
    I18n.locale =  if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym)
      params[:locale]
    else
      I18n.default_locale
    end
  end
end