Picker values localization #25329
Replies: 2 comments 1 reply
-
Interesting problem. I worked on TranslateBinding SirJohnK/LocalizationResourceManager.Maui#16 but if there's an issue with it, I can definite look at fixing it. But, outside of TranslateBinding, the main issue is will the Picker respond to MVVM changes on the ItemDisplayBinding whilst the Picker is active? Having an answer to that question will help narrow down the problem. If you're not sure what I'm talking about. I could find time to create a repro case myself, but, it would be helpful if you are able to do that investigative work. |
Beta Was this translation helpful? Give feedback.
-
I believe the real issue is:
To work around the problem, I moved the TranslateBinding to your view model, by changing the Picker.ItemDisplayBinding to ItemDisplayBinding="{Binding DisplayBinding}" and then implementing DisplayBinding in your view model: public BindingBase DisplayBinding { get; } = new Binding("Localization", converter: new TranslateConverter());
internal class TranslateConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
=> (value is string s) ? PickerLocalizationIssue.Resources.Localization.AppResources.ResourceManager.GetString(s) : null;
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotImplementedException();
} Whenever you change languages I call |
Beta Was this translation helpful? Give feedback.
-
What is a right way to localize picker values in MAUI? So far I have only one idea:
Use LocalizationResourceManager.Maui. But for picker values it doesn't work when app localization has been changed until app restart.
Is there any way to do it right in MAUI? Because the whole app follows culture change and translates accordingly except of pickers. It looks like there should be a way to do it elegantly.
Beta Was this translation helpful? Give feedback.
All reactions