You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
staticvoidMain(string[]args){// OOPS: Environment variable isn't set yet, and neither is the current culture the one we'll be using at invocation timevardescription=Environment.GetEnvironmentVariable("DOTNET_SYSTEM_GLOBALIZATION_CULTURE")switch{"es-ES"=>"hola",
_ =>"hello"};varoption1=newOption<string>("-x",description);newRootCommand{option1}.Invoke(args);}
The text was updated successfully, but these errors were encountered:
I wonder whether we'd approach this problem by adding a LocalizedHelpBuilder that derives from the deafult HelpBuilder and uses an ILocalizer from the Microsoft.Extensions.Localization. In such a case the Description of a Command/Option/Argument would be the invariant string/key passed to the ILocalizer and would either return the invariant or localized string in the output
If we don't want to add dependency to Microsoft.Extensions.Localization we could introduce a new System.CommandLine.Localization package (similar to the System.CommandLine.Hosting package). On the other extreme side, we could make the default Help builder use localization by default.
I am currently working on #1013 which is still work in progress which will introduce a new package System.CommandLine.Localization and add a new extension method UseLocalization to CommandLineBuilder.
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:
The text was updated successfully, but these errors were encountered: