Is there any beter way to write this?
before_filter :set_locale
def set_locale
if(params[:locale] and params[:locale].match /^(da|en|de)$/)
I18n.locale = params[:locale]
elsif session[:locale] == nil
xxx = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
if xxx.match /^(da|en|de)$/
I18n.locale = xxx
else
I18n.locale = 'en'
end
else
I18n.locale = session[:locale] || 'en'
end
session[:locale] = I18n.locale
end
on 2009-03-18 16:48
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.