动态加载RESX文件不起作用
我有一个网页,必须根据用户选择以多种不同的语言显示。为此,我对每个 asp.net 网页使用 RESX 文件。我不想在浏览器中使用自动检测语言,但我想根据用户选择再次设置语言。为了实现这一目标,我正在执行以下操作:
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("es-MX", false);
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("es-MX", false);
或者
Page.Culture = "es-MX";
Page.UICulture = "es-MX";
但是这些都没有按预期工作!我正在页面的 Init 方法中初始化文化,但它将始终显示默认语言。我正在检查这些属性的值,并且这些属性的区域性正确,但仍然没有使用 RESX 文件进行渲染。有什么想法吗?建议?
谢谢
I have a webpage that has to be displayed in several different languages based on user selection. For that, I'm using RESX files for each of the asp.net webpages. I don't want to used the automatic detection of the language in the browser, but I want to set the language, again, based in the user selection. In order to accomplish this I'm doing the following:
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("es-MX", false);
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("es-MX", false);
OR
Page.Culture = "es-MX";
Page.UICulture = "es-MX";
But neither of those are working as expected! I'm initializing the Culture in the Init method of the page but it will always display the default language. I'm inspecting the values of those properties and those have the culture correctly, but still is not being rendered using the RESX file. Any ideas? Suggestions?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果有人在使用显式本地化时遇到此问题,则必须执行以下操作:
来自 net-tutorials.com 网站:
In case someone runs into this issue when working with Explicit localization, here is what has to be done:
From the net-tutorials.com website:
试试这个
System.Resources.ResourceReader 资源读取器
= new System.Resources.ResourceReader("RES_PATH");
现在您可以使用它来加载用户语言,例如 es.resx
Try this
System.Resources.ResourceReader resourceReader
= new System.Resources.ResourceReader("RES_PATH");
Now you can use this to load users language like es.resx