Route depending on user language

Topics: Customizing Orchard
Mar 5, 2014 at 6:35 AM
Hello! I have a trouble to extends Orchard with routing depending on user language.
For example: user with english language code must automatically redirect to mysite/en, german-speaking - to mysite/de etc. And all localized content must depends on user language and have correct url prefix.

Should I modify Orchard source code or write my own extension to modify routing?
Should I write custom module?

Could anyone help me?
Mar 5, 2014 at 7:53 AM
We made a custom solution for our client' site (

Our module also depends on

We suppressed the RedirectFilter it provides, and embeded its functionality in our 'CultureRedirectFilter' instead.

Even though we did multiple hacks to the orchard core for our website, I do think we didnt do (m)any for the localization support.

We also added a custom 'token' to be used in url generation: it'll fill in the 'culture prefix' based on the page' culture.

We also have another 'token' called 'CultureSlug': this always takes the 'slug' of the master content item so that all our generated urls are the same, with the exception of the culture prefix! (read: you can have a unique title per page, but the generated url will - in our case - always contain the slug based on the english title)

ie: for 'fr-FR' cultures, the token would be replaced with 'fr', 'nl-NL' with 'nl' and so on :)

We also use the regular 'localization' support provided by Orchard.Localization and provide a fall back system:

If you request, for example, we'll first try to see if /nl/products exists, if not, it'll try /en/products instead

Also, if you would visit /products it'll first try the 'detected' culture and then does the same fallback.

Just to say: I think you should write your own module to do exactly what you want. We spend a lot of time on it, but was definitely worth it in the end!

Hope to have sparked some ideas for you ;)