.NET全球化:设置文化/的UICulture在页面上或主题?有什么不同? [英] .NET Globalization: Set Culture/UICulture on a Page or a Thread? What's the difference?

查看:223
本文介绍了.NET全球化:设置文化/的UICulture在页面上或主题?有什么不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题基本上是整个问题。在ASP.NET中,你可以通过重写InitializeCulture方法设置页面的文化/的UICulture属性,也可以设置当前线程的属性。

Question title is basically the entire question. In ASP.NET you can set the Culture/UICulture properties of a page by overriding the InitializeCulture method, or you can set the properties of the current thread.

有什么区别?什么是两者的优势/劣势?你会使用每个选项是什么情况呢?

What are the differences? What are the advantages/disadvantages of both? What situations would you use each option?

推荐答案

这两种方法最终在当前线程上设置的属性。

Both approaches ultimately set the properties on the current thread.

最大的区别是,方法支持自动检测语言 ​​- 他们可以从请求,确定语言(如果将值设置为自动,可选默认)。相比之下,方法需要一个特定的文化实例。

The biggest difference is that the Page methods support automatic language detection - they can determine the language from the request (if you set the value to "auto", optionally with a default). By contrast, the Thread methods require a specific culture instance.

有关Web应用程序,我只是使用方法,因为它们提供更多的选择和救我构建<$ C的(当然微不足道的)麻烦$ C>的CultureInfo 例如我自己。

For a web application, I'd just use the Page methods, because they provide additional options and save me the (admittedly trivial) trouble of constructing a CultureInfo instance myself.

这篇关于.NET全球化:设置文化/的UICulture在页面上或主题?有什么不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆