Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to translate the default clap strings? #1665

Closed
silvioprog opened this issue Feb 3, 2020 · 2 comments
Closed

How to translate the default clap strings? #1665

silvioprog opened this issue Feb 3, 2020 · 2 comments

Comments

@silvioprog
Copy link

silvioprog commented Feb 3, 2020

Hi.

As default, clap prints its info in English, e.g.:

USAGE:
    program

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

however, I would like to translate it to my country, for example:

Uso:
    programa

Flags:
    -h, --help       Imprime ajuda da aplicação.
    -V, --version    Imprime versão da aplicação.

(also, notice the translation from USAGE to Uso and FLAGS to Flags). But, I would like to keep the default clap argument behavior, for example, the -v/--version would keep showing the application version without any extra implementation like this:

    if cmd_args.is_present("version") {
        println!("{}", config::APP_VERSION);
        return Ok(());
    }

So, is there any clap option to change only the strings for translating but keep the original argument behavior?

TIA

@pksunkara
Copy link
Member

If you want to change whole help message, you have to implement the default clap behaviour too. To localize the other strings, we can combine it with already existing issue.

Duplicate of #380

@CreepySkeleton
Copy link
Contributor

@silvioprog You can replace default messages via App::help_message and App::version_message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants