Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation in WPF IValueConverter #171

Open
Enlooo opened this issue Dec 9, 2021 · 0 comments
Open

Translation in WPF IValueConverter #171

Enlooo opened this issue Dec 9, 2021 · 0 comments

Comments

@Enlooo
Copy link

Enlooo commented Dec 9, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant