Module: Tenzing::Localizer

Extended by:
ActiveSupport::Concern
Defined in:
lib/tenzing/localizer.rb

Instance Method Summary collapse

Instance Method Details

#invalid_locale(e) ⇒ Object



22
23
24
25
# File 'lib/tenzing/localizer.rb', line 22

def invalid_locale(e)
  flash[:error] = e.message
  redirect_to root_url
end

#set_localeObject



12
13
14
15
16
17
18
19
20
# File 'lib/tenzing/localizer.rb', line 12

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