Localization

Aug 23, 2013 at 11:00 PM
Hi,

I try to localize an application. I'm using WPF Localize Extension ( https://wpflocalizeextension.codeplex.com ). My problem is that localization doesn't seems to works with m:ui elements like LinkGroup, Link, ...

I know that my WPF Localize Extension is correct because with standard elements it works


Regards

Julien
Aug 26, 2013 at 11:46 AM
i have tried setting the values inside the code and rebuilding the assembly but it didnt make any difference - any further ideas on this?
Coordinator
Aug 26, 2013 at 1:52 PM
I'm not familiar with this extension. Maybe it's because LinkGroup and Link are not dependency objects?
Sep 11, 2013 at 9:12 PM
I found a solution in a WPF Localization Extension. This can be solved by setting the text in code behind.

in XAML :
<mui:Link x:Name="MyLinkToTranslate" ... />
in code behind
public MyView()
{
    InitializeComponent();
    //...
    new LocExtension("my:resource:string:key").SetBinding(MyLinkToTranslate, PropertyHelper<Link>.GetProperty(x => x.DisplayName));
    //...
}
class PropertyHelper :
public static class PropertyHelper<T>
{
    public static PropertyInfo GetProperty<TValue>(Expression<Func<T, TValue>> selector)
    {
        Expression body = selector;
        if (body is LambdaExpression)
        {
            body = ((LambdaExpression)body).Body;
        }
        switch (body.NodeType)
        {
            case ExpressionType.MemberAccess:
                return (PropertyInfo)((MemberExpression)body).Member;
            default:
                throw new InvalidOperationException();
        }
    }
}
Julien
Jan 30, 2015 at 7:05 PM
can you please explain that "my:resource:string:key" did you get this working ?
Thnaks