Where is the CurrentUICulture setting in Windows 7 set in terms of a .NET application?

I would like to check how my application will work in different cultures. Therefore, for testing in Windows 7, I tried to change CurrentUICulture in the system settings.

This seems to be the right option: Language for non-Unicode programs as suggested here , but it doesn't work, i.e. the application locale is still English.

I also tried this in the Region and Language dialog box:

  • Formats: change the format to another culture
  • Location: Set your current location to another country.

The question is what should I install on Windows 7 so that it affects:

 Thread.CurrentThread.CurrentUICulture 

instead of writing this:

 Thread.CurrentThread.CurrentUICulture = New CultureInfo("fr") 

Ultimately, this code should select the correct culture, get the correctly filled resource file and display it on the screen (what it does with the above line):

 Label1.Text = My.Resources.Form1Resource.TestString 

https://stackoverflow.com/a/4186262/how-to-setup-statement-in-javascript/232875#215895

+4
source share
3 answers

The pen is located on the "Keyboard and Languages" tab of the "Region and Language" control panel. Click "Install / Uninstall Languages ​​and hellip"; to get started. If you have only one user interface language installed, you will need to install one more. The master should guide you through this. You will also need to log out and log back in to see the effect.

In most cases, the CurrentUICulture property returns the first language in the list of preferred user interface languages, so setting this should be sufficient. Other languages ​​are used as backup languages ​​if the required resources are not available in your preferred language.

But the actual algorithm that CurrentUICulture uses to determine the culture of the user interface is a little more complicated:

  • First, it checks the DefaultThreadCurrentUICulture property. If it is not null , it returns any user interface culture that was set by default for all threads in the current application domain.
  • If DefaultThreadCurrentUICulture is null , it calls the GetUserDefaultUILanguage function.
    • This function checks if the current user sets the preferred user interface language, as described at the beginning. If so, he returns that language.
    • If the user has not set the user interface language, the function returns the language of the user interface that is set for the system. This is done by the administrator on the "Advanced" tab of the "Region and Language" control panel and requires a reboot in order to take effect.
    • If there is no preferred language for the system, then the default user interface language is used. This is either the language of the localized version of Windows (XP and earlier), or the language that was selected during installation (Vista and later).

Of course, this testing method can be a bit overwhelming because it changes the global settings (at least for the entire user account). Since the current UI culture is supported for the thread , you can only change it for your application thread. To do this, set the Thread.CurrentUICulture property. If your application is multithreaded, you can set the DefaultThreadCurrentUICulture property to make sure that the additional threads are in the correct culture. This question says you already found this, but I don’t understand why you do not want to use it.

Also, be careful when confusing the user interface language in the locale; They are not the same. CurrentCulture is a locale that sets elements such as date / number / time formats and sort order. CurrentUICulture is a user interface language that is associated with loading properly localized resources. They can be the same, and I believe that they often happen, but they should not be. There are times when the user may want them to be different; for example, if they speak English and prefer a localized English version, but want to see things like dates and times formatted according to their custom.

+8
source

So I tried to install the French language package for testing using different methods, and all of them failed. Both offline and online installation, as is, and after a restart. Received error code 800736B3 (for online) or no code at all for offline installation. System Update Ready for Windows 7 (390MB msu package), which is the most common way to fix this error code, was tested. There were still problems with online installers and standalone installers. After spending a total of about 4-5 hours, I begin to understand why @Cody recommends continuing to use this instead (for testing purposes):

 Thread.CurrentThread.CurrentUICulture = New CultureInfo("fr") 
0
source

You can customize the System.Globalization.CultureInfo.CurrentUICulture user interface culture on a Windows machine in: Control Panel\Clock, Language, and Region\Language :

System.Globalization.CultureInfo.CurrentUICulture

And if you want to install System.Globalization.CultureInfo.CurrentCulture in your Windows machine, go to Control Panel\Clock, Language, and Region and select Region:

System.Globalization.CultureInfo.CurrentCulture

In your code, you can simply use this to get these values:

  • Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentUICulture;

  • Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CurrentCulture;

Source: CurrentCulture vs. CurrentUICulture

0
source

Source: https://habr.com/ru/post/1485680/


All Articles