Forum: Rails I18n Automatically detect client's locale setting

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fernando P. (Guest)
on 2008-12-10 16:59
Hi,

Does I18n provide any easy feature to detect the client's browser
locale?
Christian R. (Guest)
on 2009-01-13 21:25
Hi Fernando,

had the same problem, but solving was quite easy:

I18n.locale =
request.headers['HTTP_ACCEPT_LANGUAGE'].split(',')[0].split('-')[0]

greetings
Christian

Fernando P. wrote:
> Hi,
>
> Does I18n provide any easy feature to detect the client's browser
> locale?
This topic is locked and can not be replied to.