Skip to content

Command and option descriptions are not easily localized  #1008

Open
@jonsequitur

Description

@jonsequitur

The incoming mechanisms for setting the culture via environment variables and directives (#951) don't allow a straightforward way to localize descriptions, because the parser is configured before the middleware that sets the culture gets executed.

Example:

        static void Main(string[] args)
        {
            // OOPS: Environment variable isn't set yet, and neither is the current culture the one we'll be using at invocation time
            var description = Environment.GetEnvironmentVariable("DOTNET_SYSTEM_GLOBALIZATION_CULTURE") switch
            {
                "es-ES" => "hola",
                _ => "hello"
            };

            var option1 = new Option<string>("-x", description);

            new RootCommand
            {
                option1
            }.Invoke(args);
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions