. Topicala Page Index Token

A Journal about the experiences I have developing little applications in C#, Perl, Html and Javascript and talking about things new things that I use. Always Geeky; Always Nerdy; Always poor Grammer!

I am a Software Analyst Developer working in Southport, England but living in Liverpool. I develop mainly in C# and ASP.Net. I have been developing comercial software for several years now. I maintain this site (hosted at SwitchMedia UK) as a way of exploring new technologies (such as AJAX) and just generally talking about techie geek issues. This site is developed through a host of Perl scripts and a liberal use of Javascript. I enjoy experimenting with new technologies and anything that I make I host here.

Quick Search

Web www.kinlan.co.uk

Wednesday, March 08, 2006

Google Search: C#, Finding the Locale

I have had a search against my site for finding the User Locale in C#.

There are a couple of ways that this can be done. If you are using ASP.Net you can look at the Request.UserLanguages string array to see what preferences they have set up. The first locale in the array should be the locale that they normally work. Obviously this is browser dependent and user configuration dependent.

Using this information you could then set the threads culture (so that all comparisons etc are performed with the correct culture awareness) using the following piece of code:

Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]);

If it is a Winform or Service you could get the Current Culture just by inspecting the either:

Technorati Tags
[feed], [feed], [feed], [feed], [feed], [feed], [feed], [feed], [feed], [feed], [feed]

Related Wikipedia Documents
, , , , ,

My Related Documents
, , ,

Related Amazon Books
Professional ASP.NET 2.0: / Beginning ASP.NET 2.0: / Programming ASP.NET 2.0 Core Reference: / Pro ASP.NET 2.0 in C#: /

Related Images From Flickr

Comments: [Add New]

Very interesting! I'm using it in a multilingual widget application. Thanks a lot!!!

By A Casa do Java, at Friday, June 08, 2007 11:52:00 PM