-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
KeysConverter in NET8 started converting keys to strings based on the CurrentCulture -
winforms/src/System.Windows.Forms/src/System/Windows/Forms/Input/KeysConverter.cs
Lines 332 to 354 in f7d6850
| private IList<string> GetDisplayOrder(CultureInfo? culture) | |
| { | |
| // Use CurrentCulture as default to match other TypeConverters. | |
| culture ??= CultureInfo.CurrentCulture; | |
| if (!CultureToDisplayOrder.ContainsKey(culture)) | |
| { | |
| AddLocalizedKeyNames(culture); | |
| } | |
| return CultureToDisplayOrder[culture]; | |
| } | |
| private IDictionary<string, Keys> GetKeyNames(CultureInfo? culture) | |
| { | |
| // Use CurrentCulture as default to match other TypeConverters. | |
| culture ??= CultureInfo.CurrentCulture; | |
| if (!CultureToKeyName.ContainsKey(culture)) | |
| { | |
| AddLocalizedKeyNames(culture); | |
| } | |
| return CultureToKeyName[culture]; | |
| } |
However, in .NET Framework, we were looking up names based on the CurrentUICulture - https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/KeysConverter.cs,64 from the resources like this:
AddKey(SR.GetString(SR.toStringPageDown), Keys.Next);
this code goes to ResourceManager.GetString Method (System.Resources) | Microsoft Learn
and returns
The value of the resource localized for the caller's current UI culture, or null if name cannot be found in a resource set.
Originally posted by @cadilhac in #10610 (comment)