Files
MesenCE/UI/Localization/TranslateExtension.cs
SourMesen e391fd8f9a Code: Add auto-formatting rules for C++ (clang-format) and enforce in CI via "clang-format" and "dotnet format" (#78)
* Code: Add auto-formatting rules for C++ projects (clang-format) and enforce code style via "clang-format" and "dotnet format"

* fix ui format warnings
2026-04-30 06:03:55 -07:00

30 lines
673 B
C#

using Avalonia.Markup.Xaml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mesen.Localization
{
public class TranslateExtension : MarkupExtension
{
public TranslateExtension(string key)
{
this.Key = key;
}
public string Key { get; set; }
public override object ProvideValue(IServiceProvider serviceProvider)
{
Type? contextType = null;
if(serviceProvider.GetType().GenericTypeArguments.Length > 0) {
contextType = serviceProvider.GetType().GenericTypeArguments[0];
}
return ResourceHelper.GetViewLabel(contextType?.Name ?? "unknown", this.Key);
}
}
}