使用 asp.net MVC 2,我一直在尝试让 Matt Hawley 的本地化助手在我的 Web 应用程序中工作,但我无法将 null 输入到 Language 字符串变量中。我不明白我为什么要这样做。
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);
}
}
}
我可能做错了什么?