mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-05-02 23:52:52 +08:00

eg. [CommandOption("-a|--args")] [Description(nameof(Str.GitArgs))] [Localization(typeof(Str))] public string Args { get; set; } The program will go to the autogenerated class "Str.designer.cs" of the Resx file, to looking for local value of the the resource symbol "GitArgs" , instead of displaying the original: "GitArgs"
24 lines
772 B
C#
24 lines
772 B
C#
namespace Spectre.Console.Cli;
|
|
|
|
/// <summary>
|
|
/// Indicates that a "Description" feature should display its localization description.
|
|
/// </summary>
|
|
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class)]
|
|
public class LocalizationAttribute : Attribute
|
|
{
|
|
/// <summary>
|
|
/// Gets or Sets a strongly-typed resource class, for looking up localized strings, etc.
|
|
/// </summary>
|
|
public Type ResourceClass { get; set; }
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="LocalizationAttribute"/> class.
|
|
/// </summary>
|
|
/// <param name="resourceClass">
|
|
/// The type of the resource manager.
|
|
/// </param>
|
|
public LocalizationAttribute(Type resourceClass)
|
|
{
|
|
ResourceClass = resourceClass;
|
|
}
|
|
} |