Sha256: d2fcc7cf8590be0b8d57038963acf6b3c1bdd071492c4f0adb40c0ffa6fe67f9
Contents?: true
Size: 603 Bytes
Versions: 1
Compression:
Stored size: 603 Bytes
Contents
require 'active_support/concern' module Tenzing module Localizer extend ActiveSupport::Concern included do before_filter :set_locale rescue_from I18n::InvalidLocale, with: :invalid_locale end def set_locale locale = params[:lang] locale ||= session[:locale] locale ||= ((lang = request.env['HTTP_ACCEPT_LANGUAGE']) && lang[/^[a-z]{2}/]) locale ||= I18n.default_locale I18n.locale = locale session[:locale] = I18n.locale end def invalid_locale(e) flash[:error] = e.message redirect_to root_url end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tenzing-0.0.1 | lib/tenzing/localizer.rb |