Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the 'Region and Language' OS setting programmatically

I'd like to be able to change the Region and Language settings of the operating system (Windows 7) from a C# program. I'm not against executing command-line commands but I've only gotten as far as discovering how to launch the Region and Language dialog: control /name Microsoft.RegionAndLanguage

This is a language localisation problem where Controls like DateTimePicker can only use the Windows Region and Language settings (see here for details); however updating the operating system to conform to the application's language settings extends beyond this and is ultimately the desired goal.

Suggestions and/or workarounds would be appreciated.

like image 572
Pooven Avatar asked Mar 02 '12 08:03

Pooven


People also ask

How can I change language and regional settings?

Click the Start button, and then click Control Panel. Click Clock, Language, and Region, and then click Regional and Language Options. The Regional and Language Options dialog box appears. On the Formats tab, under Current format, click Customize this format.

How do I change regional settings in Windows 11?

To change the system region settings on Windows 11, use these steps: Open Settings. Click on Time & language. Click the Language & region page on the right side.


1 Answers

The only solution I managed to implement was to modify the registry. In Windows 7, when the language is changed, a new entry is added to the Registry in the subkey: HKEY_CURRENT_USER\Control Panel\Desktop. This key will contain the entry PreferredUILanguagesPending of type REG_MULTI_SZ and its value will determine the UI language. For the change to be applied the current user needs to log off and log in again. 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 needs to be installed before it can be set. For a list of language packs check here or here. When more than 1 language pack is installed option to change the UI language will appear in Control Panel > Region and Language > Keyboards and Languages > Display language.

like image 142
Pooven Avatar answered Oct 05 '22 23:10

Pooven