1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-25 13:16:01 +00:00
Ryujinx/Ryujinx.Ava/Common/Locale/LocaleExtension.cs
Emmanuel Hansen 02714a1291
Avalonia - Add source generator for locale items (#3999)
* Add source generator for locale keys

* use locale keys in Ui subdir
2023-01-03 19:45:08 +01:00

30 lines
No EOL
734 B
C#

using Avalonia.Data;
using Avalonia.Markup.Xaml;
using Avalonia.Markup.Xaml.MarkupExtensions;
using System;
namespace Ryujinx.Ava.Common.Locale
{
internal class LocaleExtension : MarkupExtension
{
public LocaleExtension(LocaleKeys key)
{
Key = key;
}
public LocaleKeys Key { get; }
public override object ProvideValue(IServiceProvider serviceProvider)
{
LocaleKeys keyToUse = Key;
ReflectionBindingExtension binding = new($"[{keyToUse}]")
{
Mode = BindingMode.OneWay,
Source = LocaleManager.Instance
};
return binding.ProvideValue(serviceProvider);
}
}
}