Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UWP: Get current CultureInfo

For UWP there are some changes in the CultureInfo according to the blog entry CultureInfo changes in UWP. Can I take GlobalizationPreferences to get the CultureInfo correctly?

public CultureInfo GetCurrentCultureInfo()
{
    return new CultureInfo(Windows.System.UserProfile.GlobalizationPreferences.Languages[0].ToString());
}

Taken from this example.

like image 801
testing Avatar asked Feb 06 '23 06:02

testing


1 Answers

Can I take GlobalizationPreferences to get the CultureInfo correctly?

Yes you can, I've tested your method, it works well by my side.

I want to know the current language of the device (not region).

You can also use Windows.Globalization.Language.CurrentInputMethodLanguageTag to get the current enabled keyboard layout or Input.

like image 64
Grace Feng Avatar answered Feb 16 '23 09:02

Grace Feng