dotnet / dotnet/command-line-api

Command and option descriptions are not easily localized

Open
#1,008 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
3.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

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:

```csharp
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("-x", description);

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.