Routing international URLs in Symfony

29 08 2007

Symfonys I18n support is pretty neat once you’ve got the hang of it. The one thing I always missed was to have a set of URLs per culture in order to name the urls in different languages.

Consider the following: You have to build an application that is served in English, French and German.

Now you would probably name your starting page ‘homepage’. But then it would be nice to call it ‘pagedaccueil’ for your french visitors and ’startseite’ for the german speaking, wouldn’t it?

For example with this routing you can achieve just that.

homepage:
  url:
    de:   /startseite
    en:   /homepage
    fr:   /pagedaccueil
  params: [ module: home, action: index ]

Well with a bit of tweaking I managed to find a way to achieve this. It’s currently not too easy to extend the originally shipped sfRouting,you have to use a filter to achieve that but from there it’s easy.

The slightly enhanced UrlHelper functions are not yet well documented and probably not very complete either but then again I will come round to better them as time will come and request will be made.

Oh and of course you can still have your old routes working as before. I18n routes are an optional feature you get with this plugin.

Find out more about csI18nRoutingPlugin here.

, , , , , , ,