WindowsAppSDK-Samples icon indicating copy to clipboard operation
WindowsAppSDK-Samples copied to clipboard

ResourceManagement of text in XAML

Open Marv51 opened this issue 4 years ago • 4 comments

The ResourceManagement sample does not show the most common WinUI 3 case for localization: Strings in XAML files.

I was wondering how to use MRT Core with x:Uid attributes. The existence of the two resource systems has me pretty confused.

Should I just stay with "Windows.ApplicationModel.Resources.ResourceLoader"?

Marv51 avatar Nov 26 '21 13:11 Marv51

@Marv51 - instead of using the Windows.* namepsace, you should migrate to the corresponding Windows App SDK namespaces. Here are docs on Mapping of UWP APIs to Windows App SDK and MRT to MRT Core migration. The example code in the existing UWP docs still applies to WinUI3/Windows App SDK. x:UID works the same as with UWP, so you should only need to change the namespaces.

angelazhangmsft avatar Dec 01 '21 23:12 angelazhangmsft

How can I control the language used to get values for x:Uid for unpackaged Desktop apps?

I am trying to make a dynamic language change by re-creating views after changing the language in a ComboBox. In the UWP, I used Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = language; but this is not supported for unpackaged apps

HavenDV avatar Dec 05 '21 00:12 HavenDV

@angelazhangmsft I'd relabel this as a bug, see discussion at https://github.com/microsoft/WindowsAppSDK/issues/1687#issuecomment-958409414.

There's no way to access the internal MUX ResourceContext to change its qualifiers blocking this scenario.

@huichen123 @andrewleader for 👀

riverar avatar Dec 05 '21 07:12 riverar

Thanks @riverar for pointing that out!

How can I control the language used to get values for x:Uid for unpackaged Desktop apps?

@HavenDV, we reopened https://github.com/microsoft/WindowsAppSDK/issues/1687 to track that feature request.

angelazhangmsft avatar Dec 06 '21 17:12 angelazhangmsft