-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
argparse doesn't offer localization interface for "version" action #60990
Comments
The - deprecated - "version" keyword for argparse.ArgumentParser allowed for localization of the "show program's version number and exit" help text for -v/--version (output of "-h"/"--help") The new version action for add_argument does not allow this - resulting in a partially translated output for the -v/--version option. |
@thorsten sorry about the delay involved here. |
In this patch I added the '_()' localization to the '_VersionAction' default 'help'. While this is a straight forward change, I haven't tested it. It does run test_argparse.py, but that doesn't have any tests for localization. According to the discussion here: Does this use of _() really save the user effort? May be it would if they are already using the depricated version. Otherwise they could just give the version argument their own non default help line. I haven't used localization enough to know. |
I have tested the patch. It fixes the problem for me. You are right, new programs would just supply translated help to the version action. No effort would be saved. But the programs updated from the deprecated syntax may rely on a separate string list for translating strings found in argparse.py. They would lose the translation for the "--version" help without any warning. |
Dear all, As commented on PR 12711 (#12711 (review)), there is a slight issue with the proposed patch, as it translates the
However, I'm not sure I understand correctly Pavel's comment as to why merging this patch would make some old programs lose their translation for this string: since
In any case, my guess is that localized programs already explicitly pass a localized help string to the
These programs should also remain completely unaffected by this change. Thanks! Kind regards, |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: