使用asp.net MVC 2,我一直试图让Matt Hawley的Localization助手在我的Web应用程序中工作,但是我很难在语言字符串变量中输入null。我无法弄清楚为什么要这样做。
namespace MvcLocalization
{
public abstract class LocalizedControllerBase : Controller
{
public String LanguageCode { get; private set; }
protected override void Initialize(System.Web.Routing.RequestContext requestContext)
{
LanguageCode = requestContext.RouteData.Values["languageCode"].ToString();
if ( !AppConfig.SupportedLanguages.Contains(LanguageCode) )
LanguageCode = AppConfig.DefaultLanguageCode;
System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.CreateSpecificCulture(LanguageCode);
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
base.Execute(requestContext);
}
}
}
我可能做错了什么?
答案 0 :(得分:0)