From 04f014c777c5d2039573db9e300c4f22dac9d869 Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Fri, 1 Nov 2024 16:17:08 -0500 Subject: [PATCH] hotfix: Locale formatting --- src/Ryujinx/Common/Markup/MarkupExtensions.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx/Common/Markup/MarkupExtensions.cs b/src/Ryujinx/Common/Markup/MarkupExtensions.cs index 2af68b606..af917b973 100644 --- a/src/Ryujinx/Common/Markup/MarkupExtensions.cs +++ b/src/Ryujinx/Common/Markup/MarkupExtensions.cs @@ -1,6 +1,10 @@ using Avalonia.Data.Core; +using Avalonia.Markup.Xaml; +using Avalonia.Markup.Xaml.MarkupExtensions; +using Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings; using Projektanker.Icons.Avalonia; using Ryujinx.Ava.Common.Locale; +using System; namespace Ryujinx.Ava.Common.Markup { @@ -26,14 +30,22 @@ namespace Ryujinx.Ava.Common.Markup ); } - internal class LocaleExtension(LocaleKeys key) : BasicMarkupExtension + internal class LocaleExtension(LocaleKeys key) : MarkupExtension { - protected override ClrPropertyInfo PropertyInfo + private ClrPropertyInfo PropertyInfo => new( "Item", _ => LocaleManager.Instance[key], null, typeof(string) ); + + public override object ProvideValue(IServiceProvider serviceProvider) => + new CompiledBindingExtension( + new CompiledBindingPathBuilder() + .Property(PropertyInfo, PropertyInfoAccessorFactory.CreateInpcPropertyAccessor) + .Build() + ) { Source = LocaleManager.Instance } + .ProvideValue(serviceProvider); } }