除了更改线程的 CurrentCulture 之外,还有其他方法可以测试本地化吗?

发布于 2024-12-14 12:23:32 字数 339 浏览 3 评论 0原文

在 ASP .Net MVC 应用程序中。我想确保我的代码从正确区域性的资源文件中获取其字符串。我知道我可以在代码中添加类似以下内容:

Thread.CurrentThread.CurrentCulture = myCultureInfo;
Thread.CurrentThread.CurrentUICulture = myCultureInfo;

它会起作用。我只是想知道是否有一种方法可以在不修改源代码的情况下做到这一点。我记得很久以前有人向我展示,通过更改 IE 中的某些设置可以达到目的,但我不知道他到底更改了什么以及是否可以使用 Chrome 和/或 FireFox 执行类似的操作。

In an ASP .Net MVC application. I want to make sure my code is getting its strings from the resource files of the correct culture. I know I can put something like the following on the code:

Thread.CurrentThread.CurrentCulture = myCultureInfo;
Thread.CurrentThread.CurrentUICulture = myCultureInfo;

and it will work. I was just wondering if there is a way of doing it without modifying the source code. I remember someone showed me quite a while ago that by changing some setting in IE could do the trick but I do not what exactly he changed and if you can do something similar with Chrome and/or FireFox.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沩ん囻菔务 2024-12-21 12:23:32

您可以使用 web.config 中的 元素来设置区域性为某个特定值或将其设置为 auto 意味着将使用客户端设置:

<globalization culture="auto" uiCulture="auto" />

现在 ASP.NET 将使用客户端浏览器上配置的区域性。例如在 FireFox 中:

在此处输入图像描述

我还建议您阅读 以下博客文章介绍 ASP.NET 中的全球化。

You could use the element in your web.config to set the culture to some specific value or set it to auto meaning that the client settings will be used:

<globalization culture="auto" uiCulture="auto" />

Now ASP.NET will use the culture configured on the client browser. For example in FireFox:

enter image description here

I would also recommend you reading the following blog post on globalization in ASP.NET.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文