# Routes for different languages

**URL:** <https://www.ruby-forum.com/t/routes-for-different-languages/118669>\
**Category:** Rails\
**Created:** [October 29, 2007, 10:46pm UTC](https://www.ruby-forum.com/t/routes-for-different-languages/118669 "2007-10-29T22:46:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![addywaddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@addywaddy](https://www.ruby-forum.com/u/addywaddy)\
**Post date:** [October 29, 2007, 10:46pm UTC](https://www.ruby-forum.com/t/routes-for-different-languages/118669/1 "2007-10-29T22:46:16Z")

</div>

I have a before filter which localizes strings based on params[:lang].  
If :lang is “de” I want my urls to look like this:

[mysite.com/de/home/show/1](http://mysite.com/de/home/show/1)

If it’s empty, localization defaults to english and I want my url to  
look like this:

[mysite.com/home/show/1](http://mysite.com/home/show/1)

I’ve got the following partial rendered on every page to toggle  
languages:

\<%= link\_to “DE”, :lang =\> “de” %\>  
\<%= link\_to “EN”, :lang =\> nil %\>

Can I cater for both urls with one route? At the moment, I can only get  
this working with these two:

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