Localized routes

Topics: Localization, Writing modules
Oct 22, 2012 at 10:34 AM

Hi guys!

I'm using the DbTranslations module in combination with the multitenancy. Each tenant is a different language version of the site. The obstacle I just arrived at is trying to translate the hardcoded url's to pages: /searchresults in English should be /zoekresultaten in Dutch.

I implemented IRouteProvider as followed:

 

public class Routes : IRouteProvider
{
  private Localizer T { get; set; }

  public Routes()
  {
    T = NullLocalizer.Instance;
  }
}

 

Unfortunately, the routes are added before the localizer is instantiated, resulting in the routes not being translatable.

In a second attempt I tried creating an ActionFilter (or AuthenticationFilter, same result), which install the routes. Problem here is that the routes are now only added to the routetable when a visitor first hits a non-translatable page.

 

So the question is: how do I get to the translations from the application_start? That's where I want to enable the routes. Or is there another place this can be done?