Flow.Launcher/Flow.Launcher.Core/Resource/LocalizedDescriptionAttribute.cs

27 lines
778 B
C#
Raw Permalink Normal View History

using System.ComponentModel;
2022-12-21 07:51:17 +00:00
namespace Flow.Launcher.Core.Resource
{
public class LocalizedDescriptionAttribute : DescriptionAttribute
{
private readonly Internationalization _translator;
private readonly string _resourceKey;
public LocalizedDescriptionAttribute(string resourceKey)
{
_translator = InternationalizationManager.Instance;
_resourceKey = resourceKey;
}
public override string Description
{
get
{
string description = _translator.GetTranslation(_resourceKey);
return string.IsNullOrWhiteSpace(description) ?
string.Format("[[{0}]]", _resourceKey) : description;
}
}
}
}