Skip to content

[Feature] ResourceString Markup Extension for easy localization #4318

@HerrickSpencer

Description

@HerrickSpencer

Describe the problem this feature would solve

Microsoft’s current documentation shows examples of how to globalize your UI facing strings in UWP/WPF XAML by using the Uid as a lookup in an included resx file. This technique works great, but does have some limitations.

Commonly used resource string technique:

<Button x:Uid="MyButton"/>

In a blog post I wrote for #ifdef, I described the way some of our In-Box apps are handling resources with a markup extension. I'd like to add a version of that extension to the toolkit, and add some better features to it as well.

Describe the solution

With the markup extension:

<Button Content="{str:ResourceString Name=ButtonText}"/>
As you see we are using a custom markup extension to bind your content strings. We are able to simply pass in the name of the resource we want to use and get the localized string back.

Now our resource file need only contain simple names without the properties, making it much cleaner and easier to read.

One feature I'm adding to this is the ability to specify a language as well if the developer wanted to get resources from another language context.

Describe alternatives you've considered

Above I show the usage of the Uid methodology, but this limits developers to one string per Uid and forces the use of property names in resource files.

Metadata

Metadata

Labels

feature request 📬A request for new changes to improve functionality

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions