首页 文章

asp.net CurrentUICulture和resx文件

提问于
浏览
0

在我的asp.net应用程序中,我想让用户更改他的配置文件语言,然后加载相应的resx文件 .

我有两个全局.resx文件:

LocalizedText.resx

LocalizedText.pl.resx

protected void Page_Load(object sender, EventArgs e)
{  
      ...
      if (!IsPostBack)
      {
           setUserSettings(...)
      }                       
}

private void setUserSettings(...)
{
    ...
    Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("pl");
}

当用户更改其配置文件设置时,也会使用 setUserSettings(...) .

问题是它总是回退到 LocalizedText.resx 文件而不是加载 LocalizedText.pl.resx

我对它进行了重写,在Page_Load的开头,CurrentUICulture始终是“en_US” .

我试图设置UICulture和Culture属性,但它没有用 .

当我使用Page.Culture =“auto”时,当我将浏览器语言设置为“pl”时,它会加载.pl.resx文件,但这不是我想要的 .

有任何想法吗?谢谢

1 回答

相关问题