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
use proper gettext plurals forms in argparse and optparse #48641
Comments
The following code in optparse: if len(rargs) < nargs:
if nargs == 1:
self.error(_("%s option requires an argument") % opt)
else:
self.error(_("%s option requires %d arguments")
% (opt, nargs)) works for languages with plurals of n!=1 but will not work for many I've created a patch that handles missing gettext and implements it |
And while at it, replace "usage" with "Use". |
Mmm some problems with my head late at night. This patch sorts things |
Thanks for your patch. I have some remarks:
I’m adding Armin to the nosy list since he’s listed in py3k/Misc/maintainers.rst |
Now that argparse has been included in the standard library to supersede optparse, I’m not sure there is still value in fixing this bug. |
optparse is widely used, so the answer to my question is: yes, it is worth fixing. Checking argparse for the same errors is also a good idea. Dwayne: can you update your patch to address my remarks? If not, someone else or I may do it. Adding the “easy” keyword for potential bug-day contributors. |
I just checked argparse and there are similar non-optimal calls. Not all languages can use “string(s)” to express with 0, 1 or more, that’s why we have ngettext. Georg: This is a string change similar to bpo-10528. Does it need a patch and review before the beta1 too? |
Attached patch fixes the two misuses I found in argparse. I tried importing ngettext as _ngettext to comply with arpgarse’s crazy^Wpersonal <wink> import style (enforced in TestImportStar), but then I could not force xgettext to find all the strings. Rather than struggle longer with the program, I chose to add an exception for ngettext in the test. “from argparse import *” does not import ngettext, thanks to __all__, so I think my choice is simple and sensible. |
Georg approved my patch for the beta1. Steven, since you approved my other gettext-related changes, we thing it’s okay if I don’t wait for your +1. For optparse, I will review the changes later. |
Revision 87056 |
The workaround in TestImportStar is fine. The test is really just meant to make sure that __all__ contains all the current API methods, and the "_" checks were the easiest way at the time to check that. |
Updated patch for optparse. Georg: Is this okay for 3.2? Based on Steven’s decision for another patch that changed strings, these fixes won’t be backported. |
Previous version was incomplete. |
Looks like this will have to wait for 3.3, unfortunately. |
New changeset 4a5782a2b074 by Éric Araujo in branch 'default': |
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: