Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current language in CultureInfo

How to identify the operating system's language using CultureInfo? E.g. if the language in Windows is set to French, I need to identify French and load the fr resource files data.

like image 945
Sharpeye500 Avatar asked Nov 17 '10 19:11

Sharpeye500


People also ask

What is current culture in C#?

CurrentUICulture —the current UI culture (note the UI part) of a thread in a . NET application is used by the Resource Manager to look up culture-specific resources at run time. We will set the current culture and current UI culture of the application thread to the hi-IN culture.

How do I change the current culture in C#?

using namespace System; using namespace System::Globalization; using namespace System::Threading; int main() { // Display the name of the current thread culture. Console::WriteLine("CurrentCulture is {0}.", CultureInfo::CurrentCulture->Name); // Change the current culture to th-TH.

What is CultureInfo InvariantCulture in C#?

The CultureInfo. InvariantCulture property is used if you are formatting or parsing a string that should be parseable by a piece of software independent of the user's local settings. The default value is CultureInfo. InstalledUICulture so the default CultureInfo is depending on the executing OS's settings.

How do you set CultureInfo InvariantCulture?

You specify the invariant culture by name by using an empty string ("") in the call to a CultureInfo instantiation method. CultureInfo. InvariantCulture also retrieves an instance of the invariant culture. It can be used in almost any method in the System.


2 Answers

I think something like this would give you the current CultureInfo:

CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; 

Is that what you're looking for?

like image 161
Brosto Avatar answered Sep 21 '22 07:09

Brosto


This is what i used:

var culture = System.Globalization.CultureInfo.CurrentCulture; 

and it's working :)

like image 43
smukamuka Avatar answered Sep 23 '22 07:09

smukamuka