Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

From where CultureInfo.CurrentCulture reads culture

I want to know the setting or location from where System.Globalization.CultureInfo.CurrentCulture reads its value.

I am using a windows 7 laptop and have changed my system's regional and date-time settings to US.

I got my code working using below setting in web.config under

<globalization culture="en-US" />

Thanks

like image 443
TechnicalSmile Avatar asked Mar 14 '12 07:03

TechnicalSmile


People also ask

What is difference between CurrentCulture and CurrentUICulture?

CurrentCulture is for formatting of dates and currency while CurrentUICulture goes with language/translations. It will be used by ResourceManager to look up resources by culture. Namespace of CurrentCulture class is in System. Globalization while CurrentUICulture comes from System.

What is culture in asp net?

In an ASP.NET Web page, you can set to two culture values, the Culture and UICulture properties. The Culture value determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on. The UICulture value determines which resources are loaded for the page.

What is CultureInfo CurrentCulture in C#?

The CultureInfo. CurrentCulture property is a per-thread setting; that is, each thread can have its own culture. You get the culture of the current thread by retrieving the value of the CultureInfo. CurrentCulture property, as the following example illustrates. C# Copy.

What is culture in VB net?

The CultureInfo class provides culture-specific information, such as the language, sublanguage, country/region, calendar, and conventions associated with a particular culture. This class also provides access to culture-specific instances of the DateTimeFormatInfo, NumberFormatInfo, CompareInfo, and TextInfo objects.


1 Answers

the MSDN says

The culture is a property of the executing thread. This read-only property is equivalent to retrieving the CultureInfo object returned by the Thread.CurrentCulture property. When a thread is started, its culture is initially determined by calling the Windows GetUserDefaultLocaleName function.

In other words, it's based on the Thread, witch has a context... in the ASP.NET context, that comes from the Locale used in the client Browser first if using Server Variables or the System Settings on everything else.

Under this Web context you can get it using the Server.Variables method on HTTP_ACCEPT_LANGUAGE and you will get something like:

en-US,en;q=0.8,pt-PT;q=0.6,pt;q=0.4

Witch states that the client browser has 3 languages set, where the first one is en-US.

Everything from System.Globalization comes from the System definitions just like the image below shows:

enter image description here

code above is:

<p>
    <pre>System.Globalization.CultureInfo.CurrentCulture</pre> 
    is @System.Globalization.CultureInfo.CurrentCulture.EnglishName
</p>

No matter what browser is in use, the definition for System.Globalization will always come from the Operating System definition

enter image description here

like image 179
balexandre Avatar answered Sep 28 '22 17:09

balexandre