Open JerryNixon opened 7 years ago
I agree on x:Uid being part of XAML Standard. Also if there was some way to make x:Uid data driven, or to improve data-driven localization, it would be super helpful.
The use case is where you've got data coming from a service. If you're using x:Uid, you have to do a lot of jumps to keep it in XAML, or you just have to give up using x:Uid.
Could allow to define different provider and provide a default one that uses the PRI.
Wouldn't mind having fallbacks providers too, but guess one could implement their own fallback manager as a provider that uses a priority list of other providers (say top one getting strings from the network, other one getting from cache, last one falling back to local values and caching them etc.)
In addition: I would recommend we change the UWP implementation to allow for code-behind to be able to read x:Uid values,
Indeed! All XAML declarations must be read- and writeable from Codebehind. But I guess, XAML Standard isn't responsible for such things. The implementation of the XAML Engine needs to make this possible.
Implementation should be based on some specification, not ad-hoc
Also I would like to suggest an enhancement to the current x:uid UWP implementation for the XAML Standard.
Example:
<TextBlock Text={x:Uid=/MyLocalizationresw/Resources/Abort.Content}" />
Example 2:
<TextBlock x:Uid="/MyLocalizationresw/Resources/TextStyle" Text={x:Uid=/MyLocalizationresw/Resources/Abort.Content}" />
Example 3:
`
+1 to mfe-'s suggestion. Currently, I have a problem whenever I need to share string between a text block and a button, as implicit property binding forces to nest a TextBlock in Content property to avoid string duplication. E.g. ButtonUID.Content == TextBlockUID.Text
With UWP-XAML, Microsoft introduced the
x:Uid
directive as a mechanism to easily and comprehensively localize a XAML application. It automatically used the PRI subsystem to associate controls and their properties to localized values in locale-specific resource files. Since localization is important, and since thex:Uid
approach is so simple and complete, I recommend we considerx:Uid
to be part of the XAML Standard for the same of a unified approach for all XAML apps to localize their interfaces.In addition: I would recommend we change the UWP implementation to allow for code-behind to be able to read
x:Uid
values, even if it does not make sense for code-behind to write to those properties. Sometimes it makes most sense to create custom localization solutions for certain parts of an interface and reading the value of thex:Uid
directive can make that process easier.https://docs.microsoft.com/en-us/windows/uwp/xaml-platform/x-uid-directive