Skip to content

Translation in WPF IValueConverter #171

@Enlooo

Description

@Enlooo

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'.

grafik

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions