module R18n::Rails::HooksHelper::ForController
Private Instance Methods
set_r18n()
click to toggle source
Auto detect user locales and set.
# File lib/r18n-rails/hooks_helper.rb, line 44 def set_r18n R18n::I18n.default = ::I18n.default_locale.to_s locales = R18n::I18n.parse_http(request.env['HTTP_ACCEPT_LANGUAGE']) if params[:locale] locales.unshift(params[:locale]) elsif session[:locale] locales.unshift(session[:locale]) end i18n = R18n::I18n.new( locales, R18n.default_places, off_filters: :untranslated, on_filters: :untranslated_html ) ::I18n.locale = i18n.locale.code.to_sym R18n.set i18n ## To not prevent action ## Also don't use `puts` nil end