How should I implement localization with ASP.NET MVC routes?

前端 未结 2 720
北荒
北荒 2021-01-14 04:29

I\'m trying to plan for future (months away) localization of a new ASP.NET MVC site.

Trying to decide what makes most sense to do, as far as constructing the URLs an

相关标签:
2条回答
  • 2021-01-14 05:08

    I would use a different URL scheme like so :

    en.mysite.com (English)
    mysite.com (default language)
    ro.mysite.com (Romanian)
    

    etc.

    Then I would create a custom route like in this answer.

    0 讨论(0)
  • 2021-01-14 05:12

    I have exactly the same URL_mapping like you. My route also uses a constraint. Works for me.

       routes.MapRoute(
                // Route name
                "LocalizedController", 
                // URL with parameters                                             
                "{language}/{controller}/{action}",
                // Parameter defaults
                new {
                    controller = "Home", action = "Index", 
                    language = "de"
                },
                  //Parameter constraints
                new { language = @"de|en" }
    
    0 讨论(0)
提交回复
热议问题