Issue 33775: argparse: the word 'default' (in help) is not marked as translatable (original) (raw)

Issue33775

Created on 2018-06-05 22:12 by woutgg, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 12711 open eamanu,2019-04-07 02:53
Messages (5)
msg318784 - (view) Author: woutgg (woutgg) Date: 2018-06-05 22:12
The word 'default', used to indicate default arguments in the help text (found here: Lib/argparse.py:681) is missing the gettext wrapper, causing it to be untranslatable.
msg318787 - (view) Author: woutgg (woutgg) Date: 2018-06-05 22:28
Note: the line number in the link is not correct anymore, I'm not sure how to link to a specific commit so here is the source line: `help += ' (default: %(default)s)'`.
msg339543 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-04-06 19:55
@paul.j3 I assume this is an easy issue of wrapping "default" with _() at [0]. There doesn't seem to be any tests for localization in argparse. https://github.com/python/cpython/blob/2ea8099523581cf2ecc060831a53debb57ff98ee/Lib/argparse.py#L682
msg339547 - (view) Author: paul j3 (paul.j3) * (Python triager) Date: 2019-04-06 21:35
I haven't paid much attention to the localization issues in `argparse`. The issue is with the help modification done by the: class ArgumentDefaultsHelpFormatter help += ' (default: %(default)s)' This formatter is a convenience, not something critical. The programmer could always include that 'default' string in the help line with their preferred terminology. They don't have to use this formatter to show the default values in their help lines. _() is used mostly for error messages with the format msg = _('message %(value)s') raise Error( msg % args) So the following change might work: help += _(' (default: %(default)s)') But I'm not in a position to test it or evaluate its usefulness.
msg339549 - (view) Author: paul j3 (paul.j3) * (Python triager) Date: 2019-04-06 21:40
https://bugs.python.org/issue16786 points out that the 'version' action isn't localizable either.
History
Date User Action Args
2022-04-11 14:59:01 admin set github: 77956
2021-08-08 14:13:35 jdetrey set versions: + Python 3.6, Python 3.7, Python 3.9, Python 3.10, Python 3.11
2019-04-07 02:53:53 eamanu set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest12636>
2019-04-06 21:40:03 paul.j3 set messages: +
2019-04-06 21:35:44 paul.j3 set messages: +
2019-04-06 19:55:12 xtreak set versions: + Python 3.8nosy: + paul.j3, xtreakmessages: + components: + Library (Lib)
2018-06-05 22:28:32 woutgg set messages: +
2018-06-05 22:12:35 woutgg create