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:
Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
or
Thread.CurrentThread.CurrentCulture.ThreeLetterISOLanguageName;
or
Thread.CurrentThread.CurrentCulture.ThreeLetterWindowsLanguageName
or
Thread.CurrentThread.CurrentCulture.EnglishName;
or
Thread.CurrentThread.CurrentCulture.DisplayName;

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
[[posterous-content:cFCCcisIcvmggcnzhsAq]][[posterous-content:bnhtnykFCcgJgctwsqGD]][[posterous-content:uGJkdaBqClsflEolCFIb]][[posterous-content:sumaIDEBgnHFlptBucbE]][[posterous-content:uooIwjmhdhGkHvCIazfi]]