Get the user locale from http headers
def extract_locale_from_header
unless request.env['HTTP_ACCEPT_LANGUAGE'].nil?
return request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
end
'en'
end
This way you can determine on server side the locale of the user currently entered your site.
Comments