Skip to content

Commit

Permalink
Fix localizatin bindings not working
Browse files Browse the repository at this point in the history
  • Loading branch information
aetherstrata committed Feb 9, 2024
1 parent 696adf9 commit 9183b0c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Aosta.Ava/Aosta.Ava/Localization/LocalizeExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// See the LICENCE file in the repository root for full licence text.

using System;

using Avalonia.Data;
using Avalonia.Data.Core;
using Avalonia.Markup.Xaml;
using Avalonia.Markup.Xaml.MarkupExtensions;
Expand All @@ -14,13 +16,17 @@ internal class LocalizeExtension(string key) : MarkupExtension
public override object ProvideValue(IServiceProvider serviceProvider)
{
var path = new CompiledBindingPathBuilder()
.SetRawSource(key)
.SetRawSource(Localizer.Instance)
.Property(
new ClrPropertyInfo("Item", static o => Localizer.Instance[(string)o], null, typeof(string)),
new ClrPropertyInfo("Item", _ => Localizer.Instance[key], null, typeof(string)),
PropertyInfoAccessorFactory.CreateInpcPropertyAccessor)
.Build();

var binding = new CompiledBindingExtension(path);
var binding = new CompiledBindingExtension
{
Mode = BindingMode.OneWay,
Path = path,
};

return binding.ProvideValue(serviceProvider);
}
Expand Down

0 comments on commit 9183b0c

Please sign in to comment.