Pre loader

How do I handle localization of annotations?

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1
0

When I put localized text in my annotations, and the user selects a different language while the chart is showing, do I have to rebuild my annotations?
I had hoped that I could register ‘globalized’ texts in my annotation object, and localize them in the getter method, but it seems that the getter method is not called every time the annotation text is displayed in a ToolTip

Version
7.0.2.27161
  • You must to post comments
1
0

This is a great problem for MVVM Annotations API to solve

If your annotations are generated using our MVVM API, then the BaseAnnotationViewModel.Text or BaseAnnotationViewModel.Tooltip properties can be bound to keys and using a converter, can localise the string.

for example, given an annotation declared like this:

<Annotation Tooltip={Binding Path=TooltipKey, Converter={StaticResource LocalisationConverter}}/>
  • TooltipKey is a key which contains what message to display + language
  • Localisation converter is a custom converter you’ve created to lookup the key and turn it into a string for the user

e.g. if you have TooltipKey = “Warning_Eng” then the converter returns ‘Warning this is bad”
but if TooltipKey = “Warning_Fr” then the converter returns “attention, c’est mauvais!”

How to inject the converter into the binding if you’re using our MVVM API? That part’s going to require an example (which will take our team a while to create)

let me know if this is helpful so far

Best regards
Andrew

  • You must to post comments
1
0

@Andrew
My AnnotationViewModel does inherit from BaseAnnotationViewModel, and the getter method for the tooltip text implements the localization. All I was missing was to invoke OnPropertyChanged on the annotations collection when the user switches locale.
Your solution based on a converter is probably more elegant though.

  • Andrew Burnett-Thompson
    Of course! OnPropertyChanged will do it. Converters are nice but to inject a style into the binding between Annotation and AnnotationViewModel would require overriding styles. Have you got a solution now?
  • Søren Bech Christensen
    Yes, I’m good for now :-)
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.