Change server root to set locale but keep routes

Given the following URL as a base:

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/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:

http://www.domain.com

the server is:

http://www.domain.com/en

?

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?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs