Change software "Region and language" programmatically

I want to change the region and language of the operating system (Windows 7) from a C # program. I am not opposed to executing command-line commands, but I only got to the point of opening the Region and Language dialog box: control /name Microsoft.RegionAndLanguage

This is a language localization problem where Control like DateTimePicker can only use the region and Windows language settings (see details here); however, updating the operating system in accordance with the application language settings is beyond the scope of this and ultimately is the desired goal.

It would be helpful to discuss and / or workarounds.

+5
source share
6 answers

The only solution I managed to implement was to change the registry. In Windows 7, when changing the language, a new entry is added to the registry in the subkey: HKEY_CURRENT_USER\Control Panel\Desktop . This key will contain a PreferredUILanguagesPending entry of type REG_MULTI_SZ , and its value will determine the interface language. In order for the changes to be applied, the current user must log out and log back in. This can be done using the following code:

 RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true); string[] lang = {"en-ZA"}; key.SetValue("PreferredUILanguagesPending", lang, RegistryValueKind.MultiString); 

The language pack must be installed before installing it. For a list of language packs, check here or here . If more than 1 language pack is installed, Control Panel > Region and Language > Keyboards and Languages > Display language appears to change the user interface Control Panel > Region and Language > Keyboards and Languages > Display language .

+4
source

It sounds to me as if changing the Culture / UICulture of your application should be sufficient

eg.

 Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE"); 
+3
source

I found a good replacement for DateTimePicker : http://www.visualhint.com/fieldpackeditor

You will have the same problems with all system controls and system dialogs, such as OpenFileDialog , PrintDialog , etc., they are not localized in .NET.

But thinking about it, why do you want to change the culture for your application? The user can independently change the settings for his region and language using the control panel, why will your application overwrite these settings?

+1
source

I think you are thinking the opposite of what you need. Often, applications may need help / honor / satisfaction of user OS settings than changing them for the convenience of the application. Take a look at a message with a problem similar to yours: How do I change the regional settings / date format of a Windows user?

0
source

I found a solution here: https://support.microsoft.com/de-de/help/2764405/how-to-automate-regional-and-language-settings-in-windows-vista-window

You need to create an XML file with the following contents:

 <gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend"> <gs:UserList> <gs:User UserID="Current"/> </gs:UserList> <gs:UserLocale> <gs:Locale Name="en-US" SetAsCurrent="true"/> </gs:UserLocale> </gs:GlobalizationServices> 

Then run this command:

 control intl.cpl,, /f:"<path to XML file>" 

This will set the format to English (United States) for the current user.

Although an article on Windows Vista, it also works on Windows 7.

0
source

This is a language localization issue in which controls such as DateTimePicker can only use Windows> Region and Language Settings

NUTS. Jokes aside. Think about what you are doing here; I run your program and you reconfigure my entire computer to create a small user interface element? Preferably without asking or telling me?

There are laws against this - it can be considered as unauthorized manipulation of a computer.

Use the right control and program correctly; but do not sabotage at this level.

-one
source

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


All Articles