This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: argparse: the word 'default' (in help) is not marked as translatable
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: paul.j3, woutgg, xtreak
Priority: normal Keywords: patch

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/ 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.
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

points out that the 'version' action isn't localizable either.
Date User Action Args
2022-04-11 14:59:01adminsetgithub: 77956
2021-08-08 14:13:35jdetreysetversions: + Python 3.6, Python 3.7, Python 3.9, Python 3.10, Python 3.11
2019-04-07 02:53:53eamanusetkeywords: + patch
stage: patch review
pull_requests: + pull_request12636
2019-04-06 21:40:03paul.j3setmessages: + msg339549
2019-04-06 21:35:44paul.j3setmessages: + msg339547
2019-04-06 19:55:12xtreaksetversions: + Python 3.8
nosy: + paul.j3, xtreak

messages: + msg339543

components: + Library (Lib)
2018-06-05 22:28:32woutggsetmessages: + msg318787
2018-06-05 22:12:35woutggcreate