我已在我的MVC3申请中实施当地化。
i 寻求在“行动基金”执行之前建立当前文化的解决办法。
i) 欲从乌勒获得目前的文化:
routes.MapRoute(
"Language",
"{culture}/{controller}/{action}/{id}",
new { culture = "en", controller = "Page", action = "Index", id = UrlParameter.Optional }
);
在基地控制器中,可以做到:
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
var culture = filterContext.RouteData.Values["culture"] ?? ConfigurationSettings.AppSettings["DefaultCulture"];
var cultureInfo = CultureInfo.GetCultureInfo((string)culture);
Thread.CurrentThread.CurrentCulture = cultureInfo;
Thread.CurrentThread.CurrentUICulture = cultureInfo;
base.OnActionExecuting(filterContext);
}
i 希望在http://module上更新申请,并确立目前文化。
at the moment my code looks like this:
public void Init(HttpApplication httpApplication)
{
httpApplication.BeginRequest += (sender, eventArgs) =>
{
var defaultCulture = ConfigurationSettings.AppSettings["DefaultCulture"];
CultureInfo cultureInfo = CultureInfo.GetCultureInfo(defaultCulture);
try
{
Thread.CurrentThread.CurrentCulture = cultureInfo;
Thread.CurrentThread.CurrentUICulture = cultureInfo;
}
catch { }
};
}
• 如何利用过滤文化建立现有文化。 LineData.Values [“文化”] in the httpmodule ?
感谢您提供的任何帮助
Ori