Change server root to set locale but keep routes

Given the following URL as a base:

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

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

the server is:


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?