2

I have set the system locale to Chinese (Simplified PRC) via

ControlPanel >> Region and Language >> Administrative >> Change System locale 

I then restarted my computer and run my .NET 4.0 application.

Running

Thread.CurrentThread.CurrentCulture.Name 

Returns

en-GB 

Why?

2
  • try: Thread.CurrentThread.CurrentUICulture.Name (notice the UI) Commented Aug 8, 2013 at 13:20
  • I get the same behavior with Thread.CurrentThread.CurrentUICulture.Name Commented Aug 8, 2013 at 13:25

2 Answers 2

2

MSDN says that

Information, such as the default culture and format patterns, is cached the first time it is requested. That information can change during the life of the AppDomain, for example, when the user modifies the regional and language options portion of Control Panel. However, the CultureInfo class does not automatically detect changes in the system settings.

call this first

 Thread.CurrentThread.CurrentCulture.ClearCachedData(); 
Sign up to request clarification or add additional context in comments.

4 Comments

I can get Thread.CurrentThread.CurrentCulture.Name to return the expected value by setting Region and Language >> Formats to Chinese (SImplified PRC). Is this expected behavior? The culture exposed in .NET seems to be only affected by this "Format" setting.
@Ben i didn't get your question
Changing ControlPanel >> Region and Language >> Administrative >> Change System locale does not seem to change the value exposed in Thread.CurrentThread.CurrentCulture.Name. Instead, according to my experiments, setting Control Panel >> Region and Language >> Formats does. Is this per your understanding. I presumed setting the "Locale" in the control panel would set the locale in .NET.
i will have to check what change System Local does. Though MSDN does say that changing default format affects the culture
-1

Looks like the place to see the system locale is System.Text.Encoding.Default

PS: The "...Change system locale" affects the ANSI codepage used for "non-Unicode" applications (the *A() calls from Win32 API). In most cases .NET applications do not need to care about it because they use Unicode strings and Unicode API. But I have to interact with non-unicode application, so I need to inquire the current system locale.

2 Comments

I think that must be wrong. I see nothing relevant to culture, just encodings.
"System locale" is not much relevant to culture, however de understand it, as well, it is "just encoding"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.