我应该如何实现与ASP.NET MVC路线本地化? [英] How should I implement localization with ASP.NET MVC routes?
问题描述
我试图规划未来的一个新的ASP.NET MVC网站(几个月后)的本地化。
I'm trying to plan for future (months away) localization of a new ASP.NET MVC site.
试图决定什么最有意义的事,只要构建URL和路由。
Trying to decide what makes most sense to do, as far as constructing the URLs and routing.
比如我应该立即开始了与这样的:
For instance should I start off immediately with this :
http://www.example.com/en/Products/1001
http://www.example.com/es/Products/1001
或只是
http://www.example.com/Products/1001
再后来添加其他语言
and then add other languages later
http://www.example.com/en/Products/1001
现在这就是我的基本的主要问题,试图让路由正确。我想我的网址是由搜索引擎可转位正确。我甚至不知道如果我想在URL中的语言,但我不认为有,不会混淆搜索引擎一个不错的选择。
Thats my basic main issue right now, trying to get the routing correct. I want my URLs to be indexable by a search engine correctly. I'm not even sure if I want language in the URL but I dont think there is a good alternative that wouldn't confuse a search engine.
它导致各种像'不应该我本地化字产品'但现在我只是想获得到位的路由之前,我推出英文网站的其他问题。
It leads to all kinds of other questions like 'shouldnt I localize the word products' but for right now I just want to get the routing in place before I launch the english site.
推荐答案
我有完全像你一样URL_mapping。我的路线也使用了约束。
我的作品。
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" }
这篇关于我应该如何实现与ASP.NET MVC路线本地化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!