I am developing WinUI 3 app, currently stuck with localization. Although I wrote separate resw resource files for different cultures and localized with x:Uid
I cannot find a way to change language in app runtime.
Setting Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride
only works fine for settings startup language.
Is runtime localization in WinUI 3 even possible?
CodePudding user response:
I think you're on the right track. If you are trying to change the language at runtime, call a method that will set Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride
to the new language "string". But then after that, you will also have to
There is a frame in main window which navigates to main page. There is only one button on main page which leads to LanguagePage on click.
Goal is to change language, clear navigation stack and navigate back to main page. However, various scenarios in SetAppLanguage
didn't produced wanted result.
Please take a look at https://www.py4u.net/discuss/731870 - tried all scenarios, no effect on GUI.
Nevertheless Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView();
is throwing a COMException: 'Resource Contexts may not be created on threads that do not have a CoreWindow. (0x80073B27)'