问题
I am trying to format the datetime value using Current Culture in WinRT. But CurrentCulture property not seems to respect the System Culture.
I tried the following two properties,
System.Globalization.CultureInfo.CurrentCulture.DisplayName
System.Globalization.CultureInfo.CurrentUICulture.DisplayName
Both gives English (United States) even though I change the region in Control Panel. But this works perfectly fine for WPF. What am I doing wrong?
回答1:
WinRT uses APIs exposed in Windows.Globalisation namespace. Have a look at ApplicationLanguages class
http://msdn.microsoft.com/en-us/library/windows/apps/hh972395.aspx
This class exposes Languages, ManifestLanguages and PrimaryLanguageOveride properties
回答2:
To get the InvariantCulture settings we can use,
"ApplicationLanguages.PrimaryLanguageOverride = CultureInfo.InvariantCulture.TwoLetterISOLanguageName;"
This worked for me.
回答3:
Modern applications make use of the user language list to determine what the default application language should be and the application language is used to initialize the CurrentCulture and CurrentUICulture. Desktop apps (wpf) initialize these to the user's default UI language and locale.
One of two things is happening: your application is being built with a limited set of language resources that has en-US as the default and you do not include any of these languages in your user language list or en-US is the first language in your user language list for which you have resources in your app.
来源:https://stackoverflow.com/questions/15087075/current-culture-is-wrong-in-winrt