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

28 lines
784 B
C#
Raw Normal View History

2020-02-25 16:38:47 +00:00
using System.ComponentModel;
using Wox.Core.Resource;
namespace Wox.Core
{
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;
}
}
}
}