-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: Localization Formats
Exactly, if you plan to update the UI on language changes, then the properties using the localization dictionary need to notify when dictionary changes.I'm assuming that this property would need to send an IPropertyNotification for when the language or the title key changed to render correctly?
Thanks for sharing this! it is valuable for other users for sure.I ended up writing a converter so I could do this in the markup
-
- garethrobinson
- Posts: 11
- Joined:
Re: Localization Formats
There's a few annoyances that come with not supporting this.We decided not to support that scenario, as the ViewModel could return the localized string directly in the bound property. So instead of using the Loc extension, you would do a normal binding:I'd like to do something like:
<Label Content={noesis:Loc {Binding TitleKey}} />
But it doesn't seem to work, is there a way to make this work?Code: Select all<Label Content="{Binding TitleKey"/>
Firstly, it means you need a parallel implementation in code managing the localization, including every single ViewModel in your application being notified of a change in localization so it can update any bound strings.
Secondly, it doesn't play as nicely if you're using Studio, it's a little complex to explain but when you're using Studio you end up with two applications setting data (Studio and your app) and it'd be much easier to have them setting keys and have the final template localize that data rather than doing it upstream in multiple places. It would also allow embedding properly localized static data sets inside the xaml which means you don't have to duplicate data between Studio and your codebase and deal with differences between the design and what runs in app.
Doing something like
Code: Select all
<Label Content={noesis:Loc {Binding TitleKey}} />
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: Localization Formats
There is a technical limitation to support exactly that, and it is that MarkupExtensions are not DependencyObjects, so you can't resolve a Binding in one of its properties. But one thing we can possible do is expose a different property that stores the binding itself and we internally resolve that binding, something like:
What do you think of this approach?
Code: Select all
<Label Content="{noesis:Loc BindingKey={Binding TitleKey}}"/>-
- garethrobinson
- Posts: 11
- Joined:
Re: Localization Formats
Yes, it seems to me like that would work!
Who is online
Users browsing this forum: No registered users and 7 guests