wpfxamllocalizationivalueconverter

IValueConverter and Localization


I am currently using an IValueConverter to convert Boolean Values to Yes/No text to display in the RadGridView.

Public Function Convert(value As Object, targetType As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
            Return If(CBool(value), "Yes", "No")
        End Function

As you can see, this is my current implementation, and I was wondering how can I use localization to it and display Yes/No in other languages?

Can someone kindly help me out with this?


Solution

  • There are many ways to implement localization in the WPF UI.

    Either using Microsoft's Localisation Procedure

    or with Resource file methods. There are quite a few implementations of this that makes localization way easier than the Microsoft's method which has some overhead like giving Uid's to all elements to be localized and sorts.

    One such plugin giving a resource file localization is Infralution WPF Localization

    This seems to work well(author active in replying to bugs in code-project, updates are prompt and MVVM friendly). It's attached example demonstrates a similar example to yours where the author shows how binding a value in the view can be localized at run-time based on a set of target values it can accept.

    I'd suggest you read through the code-project article, Mess about with the accompanying example and you should have a much better idea of how to implement this.