mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
30 lines
972 B
C#
30 lines
972 B
C#
using System.ComponentModel;
|
|
using CommunityToolkit.Mvvm.DependencyInjection;
|
|
using Flow.Launcher.Plugin;
|
|
|
|
namespace Flow.Launcher.Core.Resource
|
|
{
|
|
public class LocalizedDescriptionAttribute : DescriptionAttribute
|
|
{
|
|
// We should not initialize API in static constructor because it will create another API instance
|
|
private static IPublicAPI api = null;
|
|
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
|
|
|
|
private readonly string _resourceKey;
|
|
|
|
public LocalizedDescriptionAttribute(string resourceKey)
|
|
{
|
|
_resourceKey = resourceKey;
|
|
}
|
|
|
|
public override string Description
|
|
{
|
|
get
|
|
{
|
|
string description = API.GetTranslation(_resourceKey);
|
|
return string.IsNullOrWhiteSpace(description) ?
|
|
string.Format("[[{0}]]", _resourceKey) : description;
|
|
}
|
|
}
|
|
}
|
|
}
|