Localization #269
Answered
by
CyberSinh
Skeferstat
asked this question in
Q&A
Localization
#269
-
Hi, can I use a localized text in the decription attribute from spectre.cli? public class Settings : CommandSettings |
Beta Was this translation helpful? Give feedback.
Answered by
CyberSinh
Apr 17, 2023
Replies: 1 comment
-
Hi, Attributes only support constant values. But you can workaround this limitation like this: internal sealed class LocalizedDescriptionAttribute : DescriptionAttribute
{
public string Key { get; }
public LocalizedDescriptionAttribute(string key) :
base(SRCli.ResourceManager.GetString(key) ?? throw new ArgumentOutOfRangeException(nameof(key)))
{
Key = key;
}
}
internal sealed class ConfigureCommandSettings : CommandSettings
{
[CommandOption("--name")]
[LocalizedDescription(nameof(SRCli.NameOption))]
public string? Name { get; init; }
} Hope this helps. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
patriksvensson
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Attributes only support constant values. But you can workaround this limitation like this:
Hope this helps.