dotnet / dotnet/command-line-api
Command and option descriptions are not easily localized
- 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
Assessment
This issue has not been assessed yet.