I'm writing a UWP app that supports localization. When testing on different machines I get opposite values for Culture
and UICulture
.
When both machines are set in Windows 11 to be Español (Estados Unidos)
and have the Windows UI in Spanish, they returns swapped results:
System.Globalization.CultureInfo.CurrentCulture
returnsen-US
on one machine andes-US
on another machine.System.Globalization.CultureInfo.CurrentUICulture
returnses-US
on one machine anden-US
on another machine.
This causes the localization not to work on the machine that returns en-US
incorrectly for CurrentUICulture
(i.e. it display the app in English instead of Spanish).
Interestingly enough, PowerShell returns the opposite values - Get-Culture
returns the same value as CultureInfo.CurrentUICulture
and Get-UICulture
returns the same value as CultureInfo.CurrentCulture
.
How can I get consistent behavior from Windows?
CodePudding user response: