I18n.locale Setting invalid

I like this set of


before_filter :set_language

def set_language

  request_language = request.env['HTTP_ACCEPT_LANGUAGE']

  request_language = request_language.nil? ? nil : request_language[/[^,;]+/]

  I18n.locale = request_language if request_language && File.exist?("#{Rails.root.to_s}/config/locales/#{request_language}.yml")


if i setting config/application.rb:

config.i18n.default_locale = :zh

It can work, but not by ‘HTTP_ACCEPT_LANGUAGE’…

I did the right thing?

Don’t you need a .to_sym on it as i18n expects a symbol only I think.