通过 MVC 实现全球化
我正在尝试本地化我的网页,并完成了以下操作:
添加了带有一些示例字符串的资源文件
添加了对方法的调用,以在标志图标的单击事件上设置文化和 ui 文化:
public void SetCulture(string culture)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
}
并且我已经引用了我的资源我的网页中的文件字符串:
@Resources.General.String1
我已经单步执行了我的代码,并且在我的 SetCulture 方法中成功更改了区域性,但该字符串在网页上没有更改。有人可以建议为什么吗?
I am trying to localize my web page, and have done the following :
Added resource files with some example strings
Added a call to a method to set culture and ui culture on the click event of flag icons :
public void SetCulture(string culture)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
}
And I have made reference to my resource file strings in my web page :
@Resources.General.String1
I have stepped through my code and the culture is successfully changed in my SetCulture method, but the string does not change on the web page. Can anybody advise why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不明白您所说的 ASP.NET MVC 应用程序中的单击事件是什么意思。我将使用路由来设置新语言。您可以在 Localization with ASP.NET MVC 中找到示例使用路由。
您必须重新加载整个页面,而不是使用 Javascript 事件。
I don't understand what you mean with the click event in a ASP.NET MVC application. I would use routing to set the new language. A sample you can find at Localization with ASP.NET MVC using Routing.
Instead of using a Javascript event, you have to reload the whole page.