# Change server root to set locale but keep routes

**URL:** <https://www.ruby-forum.com/t/change-server-root-to-set-locale-but-keep-routes/184531>\
**Category:** Rails\
**Created:** [March 3, 2010, 11:59pm UTC](https://www.ruby-forum.com/t/change-server-root-to-set-locale-but-keep-routes/184531 "2010-03-03T23:59:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![partydrone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a6a055/32.png) [@partydrone](https://www.ruby-forum.com/u/partydrone)\
**Post date:** [March 3, 2010, 11:59pm UTC](https://www.ruby-forum.com/t/change-server-root-to-set-locale-but-keep-routes/184531/1 "2010-03-03T23:59:51Z")

</div>

Given the following URL as a base:

[http://www.domain.com/resources/1](http://www.domain.com/resources/1)

I want to insert locale information after the server like this:

[http://www.domain.com/en/resources/1](http://www.domain.com/en/resources/1)  
[http://www.domain.com/es/resources/1](http://www.domain.com/es/resources/1)

Has anyone thought of a way to “expand” the server root to include  
additional information in the path, so that instead of the server  
being:

> **[Website Domain Names, Online Stores & Hosting](https://www.domain.com)**
>
> Finding the perfect website domain is as easy as 1-2-3. Buy a domain name, build and host a website, and enjoy our professional online marketing tools.

the server is:

> **[Website Domain Names, Online Stores & Hosting](https://www.domain.com/)**
>
> Finding the perfect website domain is as easy as 1-2-3. Buy a domain name, build and host a website, and enjoy our professional online marketing tools.

?

I’m wondering if rack is the best way to intercept the request to  
Rails and “extend” the server portion of the URL to include the locale  
information in a way that won’t break my Rails routes.

I’ve read many of the Rails i18n articles out there, and am aware of  
methods of determining the locale from TLDs, subdomains, or query  
strings. I specifically want to explore this option of including the  
locale at the beginning of the path without breaking my routes helpers  
(i.e., resources\_path(@resource\_id), etc.).

Any thoughts?
