Skip to content

Enhancement: Make Cli ArgumentParsers locale configurable #8619

@JamesBoon

Description

@JamesBoon

When creating a command in dropwizard, I usually add my help texts in english. This makes sense as dropwizards help texts are english too.
But argparse4j uses Locale.getDefault() and for this reason the output is in two different languages on each non-english system.

I have two different proposals:

  1. Just change the creation of the ArgumentParser here to set the english locale:
    final ArgumentParser p = ArgumentParsers.newFor(usage).locale(Locale.ENGLISH).addHelp(false).build()
    This would be a breaking change though. But maybe possible for 5.0.0?

  2. Or: Make it possible to somehow pass more options to the creation of the ArgumentParser. Maybe by enhancing JarLocation. It could return the locale in a function like getLocale() (default: Locale.getDefault()). Then a protected Function of Application<> like getJarLocation() could be used here:
    final Cli cli = new Cli(getJarLocation(), bootstrap, System.out, System.err);
    and the line from "1." would become:
    final ArgumentParser p = ArgumentParsers.newFor(usage).locale(location.getLocale()).addHelp(false).build()

What do you think? Is one of these ways possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleStale issue or pull request which will be closed soon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions