routes, default_url_options and languages


My app is available in 2 languages, English (en) and French (fr).

I would like all my URLs to look like this :



I’ve setup this route :

map.connect ‘:lg/:controller/:action/:id’

I don’t want to specify the :lg parameter in every url_for calls.

The language remains the same unless the params[:change_lg] is set.

In my application.rb, I’ve written this :

def default_url_options(options)

{ :lg => params[:change_lg].nil? ? session[:language] : params[:change_lg] }


My problem :

When I use <?=companies_path ?> in my view, here is the URL that is generated :


What I would like to have instead :


Has anyone an idea?

Would be much appreciated.

Thanks in advance,


Are you talking about a plugin I can find here ?

Which one are you talking about?


did you find a solution for this?

Cheers, derkaan

Thomas Balthazar wrote: