From adf113c9fa377ff3c75b096e2a6f50cfd4f6f856 Mon Sep 17 00:00:00 2001 From: eamanu Date: Sat, 6 Apr 2019 23:33:54 -0300 Subject: [PATCH 1/2] Add the words 'default' and 'version' help text localizable. Co-authored-by: paul.j3 --- Lib/argparse.py | 4 ++-- .../next/Library/2019-04-06-23-50-59.bpo-33775.0yhMDc.rst | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2019-04-06-23-50-59.bpo-33775.0yhMDc.rst diff --git a/Lib/argparse.py b/Lib/argparse.py index 798766f6c4086a..08e0a7933e6b53 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -679,7 +679,7 @@ def _get_help_string(self, action): if action.default is not SUPPRESS: defaulting_nargs = [OPTIONAL, ZERO_OR_MORE] if action.option_strings or action.nargs in defaulting_nargs: - help += ' (default: %(default)s)' + help += _(' (default: %(default)s)') return help @@ -1042,7 +1042,7 @@ def __init__(self, version=None, dest=SUPPRESS, default=SUPPRESS, - help="show program's version number and exit"): + help=_("show program's version number and exit")): super(_VersionAction, self).__init__( option_strings=option_strings, dest=dest, diff --git a/Misc/NEWS.d/next/Library/2019-04-06-23-50-59.bpo-33775.0yhMDc.rst b/Misc/NEWS.d/next/Library/2019-04-06-23-50-59.bpo-33775.0yhMDc.rst new file mode 100644 index 00000000000000..2a663ac7940dcb --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-04-06-23-50-59.bpo-33775.0yhMDc.rst @@ -0,0 +1 @@ +Add 'default' and 'version' help text for localization in argparse. From db63aafd46e367a6e3d27ba452ee39e840cccf86 Mon Sep 17 00:00:00 2001 From: Oleg Iarygin Date: Sat, 15 Apr 2023 21:41:47 +0400 Subject: [PATCH 2/2] Address jdetrey's review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jérémie Detrey --- Lib/argparse.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/argparse.py b/Lib/argparse.py index 08e0a7933e6b53..e4d39427e2fa63 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -1042,7 +1042,9 @@ def __init__(self, version=None, dest=SUPPRESS, default=SUPPRESS, - help=_("show program's version number and exit")): + help=None): + if help is None: + help = _("show program's version number and exit") super(_VersionAction, self).__init__( option_strings=option_strings, dest=dest,