asp.net mvc的本地化 [英] asp.net mvc localization
问题描述
我试图实现与本土化路线
I'm trying to implement localization with routes
我有以下内容:
routes.MapRoute( "DefaultLocalized",
"{lang}/{controller}/{action}/{id}",
new { controller = "Home",
action = "Index",
id = "",
lang = "en" }
);
routes.MapRoute( "Default",
"{controller}/{action}/{id}",
new { controller = "Home",
action = "Index",
id = "" }
);
当我把我的页面域/ EN /家庭/指数
,它工作正常,但是当我打电话站点/主页/指数
我收到错误404:资源无法找到
When I call my page domain/en/home/index
, it works fine but when i call domain/home/index
I get error 404: resource cannot be found.
此外,当我在域/ EN /家庭/指数
和我点击一个安全的网页我重定向到域/帐号/登录
我怎么可以被重定向到域/ EN /帐号/登录
?
Also when I'm at domain/en/home/index
and I click a secured page I get redirected to domain/Account/login
how can I be redirected to domain/en/Account/login
?
此外,当我得到一个应用程序错误怎么可以被重定向到域/ EN /家庭/错误
?
Also when I get an application error how can I be redirected to domain/en/home/error
?
真正的问题是我怎么能实现本地化与语言作为路由参数?
The real question is how can I implement localization with language as a route parameter?
推荐答案
您也可以采用除马克Gravell和Freddy里奥斯更严格的约束。
You could also introduce a constraint even tighter than Marc Gravell and Freddy Rios.
像ZH | DE | FR | ES。这意味着硬编码语言,但通常这些都是一些而着称。
something like "en|de|fr|es". This would mean hardcoding the languages but usually these are few and known.
这篇关于asp.net mvc的本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!