设置文化时,我设置的页面文化在运行时代码隐藏这样的资源文件不工作:定位在运行时
System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
Page.Culture = "fr-FR";
资源文件是在GlobalResource文件夹,我已经有2个文件:SomeFile.resx
和SomeFile.fr.resx
在标记页面,我有文字,看起来像这样:
<asp:Literal runat="server" ID="test" Text="<%$ Resources:SomeFile, SomeKey%>" />
如果SE中的代码如果文化被注释掉,那么文字将采用SomeFile.resx
中的值,但是如果我运行设置文化的代码,那么我也会得到SomeFile.resx
文件中的值,而不是SomeFile.fr.resx
文件中的值。我也尝试将文化信息设置为“fr”,以查看这是否有所作为,但没有。
我需要改变什么?
谢谢。
设置文化后,从资源中获取字符串是否正确工作(类似于'var s = SomeResources.SomeKey;',假设您已经为resx启用了auo-generation)? – 2014-09-10 16:31:26