6

In my WPF application the CurrentUICulture is not properly taken over by Windows or is wrongly stored in Windows.

The region and language settings in Windows are in all places that I have found "Deutsch (Schweiz)". CurrentUICulture in the application displays "Deutsch (Deutschland)" instead of "Deutsch (Schweiz)". I've tested it on several computers (with domain user and local user).

Where could be the problem? Is there a place for this setting in Windows that is hard to find?

Important: I know that I can set the culture in the application. I do not need an answer like Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-ch")

I just want to find out how the mechanism works and where it gets the information from.

Here a few screenshots from my Windows settings:

welcome screen and new user accounts settings

region & language

advanced settings

region

Thanks, Adrian

Adrian
  • 101
  • 6
  • if you don't set in code / config file then it's same as `CurrentCulture` which is taken from your system local environment settings – Rahul Oct 25 '17 at 10:00
  • What is your windows display language? What OS are you on? – mm8 Oct 25 '17 at 10:00
  • OS is Windows 10, display language is "Deutsch (Schweiz)". CurrentCulture looks correctly "Deutsch (Schweiz)". But it's not the same like CurrentUICulture. In Windows, the CurrentCulture is defined under Formats not Languages. – Adrian Oct 25 '17 at 10:04
  • Could you provide some screenshot of your language settings? – mm8 Oct 25 '17 at 10:07
  • See also: [CultureInfo.CurrentUICulture](https://msdn.microsoft.com/library/system.globalization.cultureinfo.currentuiculture.aspx) section "Remarks" starting from "When a thread is started, its UI culture is initially determined as follows [...]". – Corak Oct 25 '17 at 10:31
  • @Corak: DefaultThreadCurrentUICulture is null. And the other information unfortunately does not help. – Adrian Oct 25 '17 at 10:51
  • 1
    The odds that anybody is going to write you a manual are zilch. Basic ways to get ahead is to first try this with a do-nothing console mode app, helps you diagnose whether this is a machine specific issue. Then you need to consider what is happening in that WPF app, localization crimes are pretty universal. Simply use Debug > New Breakpoint > Function Breakpoint and enter System.Globalization.CurrentCulture.set_CurrentUICulture. When it hits then you'll find the evil code back in the stack trace. – Hans Passant Oct 25 '17 at 11:47
  • @Hans Passant: Thank you for your tip. I already have a simple application that does nothing else than read the culture. Your proposed breakpoint was never hit. And I'm pretty sure it's a problem of the machine. But I do not find out where Windows or the application get this information from. – Adrian Oct 25 '17 at 12:00

1 Answers1

4

I suppose this is "by design" by Microsoft.

Please read this question. There is a pretty high upvoted comment on that:

Bear-in-mind that Microsoft, in their wisdom, don't separate the UI cultures of US English and (British) English or other Englishes. There's no MUI for English, which means the CurrentUICulture will always be en-US on an English-language machine, regardless of the CurrentCulture, which can be set to localise the Regional Settings.

While I'm not sure where this info comes from, your current OS behavior pretty confirms that: you change the regional settings (CurrentCulture), but the CurrentUICulture always stays "country agnostic" as "de-DE" (like "en-US" in the comment for any "en-*" regional setting).

dymanoid
  • 14,771
  • 4
  • 36
  • 64