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.
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.
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.
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.
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.
I think something like this would give you the current CultureInfo:
CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
Is that what you're looking for?
This is what i used:
var culture = System.Globalization.CultureInfo.CurrentCulture;
and it's working :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With