Home > Net >  Windows 11 Culture and UiCulture disagree
Windows 11 Culture and UiCulture disagree

Time:02-10

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 returns en-US on one machine and es-US on another machine.
  • System.Globalization.CultureInfo.CurrentUICulture returns es-US on one machine and en-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:

  •  Tags:  
  • Related