人生是一场不能存盘的RPG,我只能尽量多搞几个Screenshot

July 25, 2007

IE Language Preference and Culture in Page Directive

Filed under: ASP.NET

Create a web application with chinese and english resource strings.resx and strings.zh-CN.resx.
Read resource with following code:

ResourceManager L10N = new ResourceManager(”WebAppCulture.strings”, typeof(_Default).Assembly);
this.Label1.Text = L10N.GetString(”Name”);

this.Label2.Text = “Culture: “+Thread.CurrentThread.CurrentCulture.Name;
this.Label3.Text = “UICulture: ” + Thread.CurrentThread.CurrentUICulture.Name;

相关设定有:
OS
IE
Page:Culture
Page:UICulture
结果有:
CurrentThread.CurrentCulture
CurrentThread.CurrentUICulture

结论,IE Language Preference 和Page:Culture相互作用,影响当前线程的Culture.对UICulture无影响
如果不指定Page:Culture, CurrentThread.CurrentCulture为OS的culture
如果指定了Page:Culture, CurrentThread.CurrentCulture为IE指定的culture
如果不支持IE指定的culture, CurrentThread.CurrentCulture为Page:Culture指定的culture

如果不指定Page:UICulture, CurrentThread.CurrentUICulture为OS指定的culture
如果指定了Page:UICulture, CurrentThread.CurrentUICulture为Page:UICulture指定的culture

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/localization/culture.aspx#autoculture
If the first language in the list matches the name of a neutral culture supported by the .NET Framework, ASP.NET will try to use the function CultureInfo.CreateSpecificCulture() to create a specific culture for the purpose of formatting.
If the first language in the list isn’t a culture supported by the .NET Framework, ASP.NET will fall back to the culture specified after the colon in the Culture declaration.

Comments »

The URI to TrackBack this entry is: http://recordsome.blogsome.com/2007/07/25/ie-language-preference-and-culture-in-page-directive/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.






















Get free blog up and running in minutes with Blogsome
Theme designed by Hadley Wickham