Gu.Localization
Gu.Localization copied to clipboard
Translation in WPF IValueConverter
App: WPF .Net 4.6.1
I set the language of the main window to
Language = System.Windows.Markup.XmlLanguage.GetLanguage(CultureInfo.GetCultureInfo("de").IetfLanguageTag);
In any IValueConverter i get 'de-DE' as culture, which has 'de' as parent. So translating like
internal class CultureReturningConverter : IValueConverter
{
private static ITranslation SomeTranslation
= Translation.GetOrCreate(Properties.Resources.ResourceManager, nameof(Properties.Resources.SomeTranslation));
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return SomeTranslation.Translate(culture);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
is not possible, because the Translator doesn't know 'de-DE'.
Is it a wanted behavior or a bug? Should the Translator also check the parent culture on Translate(culture)?
Or is it simply a fault of mine?