-
Notifications
You must be signed in to change notification settings - Fork 975
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix InputLanguage.FromCulture() for languages without LANGID value
Many supported Windows languages do not have a unique pre-assigned LANGID to identify them and instead use a value 0x1000 (LOCALE_CUSTOM_UNSPECIFIED) since Windows 8. Windows tries to allocate and provide a unique transient value (from a pool four values: 0x2000, 0x2400, 0x2800, 0x2C00) in these cases in the HKL lowerword to distinguish between different languages via the old Win32 APIs, but these values can't be used to identify the keyboard layout directly, and in result we can't get the InputLanguage correctly in the FromCulture method. Aquire corresponging IETF BCP 47 language tag with a call to a proper API and compare locale names instead of LANGID to fix these corner cases. I tried to use CultureInfo constructor with LANGID parameter but it turns out that the LCIDToLocaleName API, which is used inside CultureInfo, may return incorrect language tags for transient language identifiers. For example, it returns "nqo-GN" and "jv-Java-ID" instead of the "nqo" and "jv-Java"(as seen in the Get-WinUserLanguageList PowerShell cmdlet). I had to use undocumented registry keys to to extract proper language tag from a LANGID. This workaround was approved by a Windows team. #8573 (comment)
- Loading branch information
Showing
4 changed files
with
138 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters