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 |
asp net [feed], culture awareness [feed], string array [feed], winform [feed], threads [feed], browser [feed], c# [feed], ThreadInfo [feed], WinForm [feed], .Net [feed], Thread Locale [feed] |
Related Wikipedia Documents |
.NET Framework, ASP.NET, Microsoft Visual Studio, Comparison of generics and templates, Web browser, C Sharp |
Related Amazon Books |
Professional ASP.NET 2.0: View From Amazon UK/View From Amazon USA Beginning ASP.NET 2.0: View From Amazon UK/View From Amazon USA Programming ASP.NET 2.0 Core Reference: View From Amazon UK/View From Amazon USA Pro ASP.NET 2.0 in C#: View From Amazon UK/View From Amazon USA |
Related Images From Flickr |
[[posterous-content:cFCCcisIcvmggcnzhsAq]][[posterous-content:bnhtnykFCcgJgctwsqGD]][[posterous-content:uGJkdaBqClsflEolCFIb]][[posterous-content:sumaIDEBgnHFlptBucbE]][[posterous-content:uooIwjmhdhGkHvCIazfi]] |