clap-rs / clap

A full featured, fast Command Line Argument Parser for Rust

Home Page:docs.rs/clap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multilingual Help Commands

Pi-Cla opened this issue · comments

Please complete the following tasks

Clap Version

4.5.4

Describe your use case

What if the user of myapp could access a help page in their own language?

Describe the solution you'd like

For example a user could type in:

myapp -h fr

to get the French version of the help page.

and developers of myapp would only need to add one more argument in order to add the translation like so:

struct Cli {
    #[arg(help = "Does thing", help(fr,"Fait la chose"))]
    thing: bool,
}

Alternatives, if applicable

No response

Additional Context

No response

All functions automatically created by Clap, hope to be able to customize messages, as blow:
#[clap(next_help_heading = "选项", version_message_zh_CN = "打印版本信息", help_message_zh_CN = "打印帮助信息")]

We have #380 for allowing clap to be localized.

Switching --help to accepting an argument would be a breaking change for applications. We could limit the scope to just applications that want support for more than one translation but that also means adopting translations is a breaking change.

I also generally view command-lines as something for state that can change run to run but I would expect this to be something to change by the user, rather than by the invocation instance, and seems like something that belongs in config.

This also feels like its verging on clap becoming a bespoke localization framework and I'd rather smooth out the path for people to choose what localization framework works for them.

With all of that, I lean towards closing this in favor of #380. If there is a reason we should re-evaluate this, let us know!