How to pass a bound value to Translate extension? Maybe I need Converter instead?

midixmidix LVMember ✭✭

I was trying to use the Translate extension from Xamarin examples:

https://github.com/xamarin/xamarin-forms-samples/blob/d8e81677d03891c204bc7c1b990992cde24fbd03/UsingResxLocalization/UsingResxLocalization/PagesXaml/TranslateExtension.cs

In general, it works, I can use {i18n:Translate some_text_value}.

But I have a list of items and each item has a TextKey which needs to be translated. I don't want to pollute my CS code with manual calls to translator; I'd like to do it in XAML.

How do I make my bound values translated?

<ListView x:Name="someistView"> <ListView.ItemTemplate> <DataTemplate> <ImageCell Text="{Binding TextKey}" /> <-- how to get these translated through TranslateExtension ? </DataTemplate> </ListView.ItemTemplate> </ListView>

Is it possible at all? Maybe I should implement Translation ValueConverter instead?

Best Answer

Answers

  • MuhammadAbuMandourMuhammadAbuMandour USMember ✭✭

    please can you explain what method return "DependencyService.Get().Trans((string)value);" will do ?

Sign In or Register to comment.