2

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?

Jawahar
  • 4,775
  • 1
  • 24
  • 47

3 Answers3

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

Hermit Dave
  • 3,036
  • 1
  • 13
  • 13
  • I tried your answer. But it still giving my "en-US'. I have set my region to Georgian (Georgia) through Control Panel region settings. I have tried following code, Windows.Globalization.Language.CurrentInputMethodLanguageTag new Windows.Globalization.NumberFormatting.DecimalFormatter().GeographicRegion – Jawahar Feb 26 '13 at 11:08
  • what are the input languages ? that's what is used – Hermit Dave Feb 26 '13 at 11:08
1

To get the InvariantCulture settings we can use,

"ApplicationLanguages.PrimaryLanguageOverride = CultureInfo.InvariantCulture.TwoLetterISOLanguageName;"

This worked for me.

Mei
  • 21
  • 3
  • 1
    Please don't do that. It's a really bad idea. The PrimaryLanguageOverride is meant to support a users choice of a specific language for an application that may not match their general preference of languages specified by their user language list. This setting is persisted across runs of the application. – Eric MSFT Oct 01 '14 at 17:51
1

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.

Eric MSFT
  • 3,246
  • 1
  • 18
  • 28