<p>How can I go about making my routes recognise an optional prefix parameter as follows:</p>

<pre><code>/*lang/controller/id
</code></pre>

<p>In that the lang part is optional, and has a default value if it's not specified in the URL:</p>

<pre><code>/en/posts/1   =&gt; lang = en
/fr/posts/1   =&gt; lang = fr
/posts/1      =&gt; lang = en
</code></pre>

<p><em>EDIT</em></p>

<p>Ideally, I'm looking to do this across many controllers and actions by mapping a namespace:</p>

<pre><code>map.namespace "*lang" do |lang|
  lang.resources :posts
  lang.resources :stories
end
</code></pre>

I'm guessing (no time to test right now) that this might work:
```
```
map.connect ':language/posts/:id', :controller => 'posts', :action => 'show'
map.connect 'posts/:id', :controller => 'posts', :action => 'show'
```
```
OK, tried it - it works, on Rails 2.1.1 at least. So that's good. Can't get the :defaults idea to work, though, which is a shame, because it's DRYer.