# Language setting before routing?

**URL:** <https://www.ruby-forum.com/t/language-setting-before-routing/57853>\
**Category:** Rails\
**Created:** [April 15, 2006, 12:57am UTC](https://www.ruby-forum.com/t/language-setting-before-routing/57853 "2006-04-15T00:57:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [April 15, 2006, 12:57am UTC](https://www.ruby-forum.com/t/language-setting-before-routing/57853/1 "2006-04-15T00:57:38Z")

</div>

When processing a request, where can you obtain the language setting of  
a user’s browser?

I know we can read @request.env[“HTTP\_ACCEPT\_LANGUAGE”] in an action  
easily. But I need to access it before being routed to a controller’s  
action… because the accepted language dictates my app’s language  
setting programmatically and what action to take. (I’m not allowed to  
ask a user to specify a preferred language using an URL.) Where in the  
Rails _runtime_ routing is done?

Any filter, plugin, or even somewhere in the Rails core? I spent 4 hours  
to poke around, but didn’t get any idea.

Thanks in advance!

DD

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [April 15, 2006, 8:26am UTC](https://www.ruby-forum.com/t/language-setting-before-routing/57853/2 "2006-04-15T08:26:17Z")

</div>

You could try to do it in routes.rb, before actual routing code. Or  
make mixin and call it from here. Will it violate some Rails  
philosophy? I don’t know.

–  
olegf

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [April 15, 2006, 6:46pm UTC](https://www.ruby-forum.com/t/language-setting-before-routing/57853/3 "2006-04-15T18:46:11Z")

</div>

Thank you, Leo, for your pointer! It looks like the recognize() method  
is the place to start… it has a user’s request and path. Hope to  
devise a change/addition that doesn’t mess up the Rails core…

DD

Leo – wrote:

> You could try to do it in routes.rb, before actual routing code. Or  
> make mixin and call it from here. Will it violate some Rails  
> philosophy? I don’t know.
> 
> –  
> olegf
