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.
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2008-12-10 15:59
Hi,

Does I18n provide any easy feature to detect the client's browser
locale?
637eabfcd8103206533e740defad8e4e?d=identicon&s=25 Christian Richter (dragonchaser)
on 2009-01-13 20: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 Perez 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.