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.
Created on 2010年11月22日 02:31 by eric.araujo, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| gettext-argparse.diff | eric.araujo, 2010年11月22日 02:31 | |||
| Messages (8) | |||
|---|---|---|---|
| msg122068 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2010年11月22日 02:31 | |
I found two calls to gettext that are incorrect. See attached patch. |
|||
| msg122076 - (view) | Author: Alexander Belopolsky (belopolsky) * (Python committer) | Date: 2010年11月22日 02:53 | |
The patch makes sense. I wonder if i10n of programs using argparse should be mentioned in docs. Providing a sample translation file somewhere may not be a bad idea at least for testing. |
|||
| msg122301 - (view) | Author: Steven Bethard (bethard) * (Python committer) | Date: 2010年11月24日 20:17 | |
Looks like a great fix. And yes, anyone who knows anything about gettext, please feel free to add a test or ten. ;-) I just copied optparse when I put that stuff in, so I have no confidence in how it's done now. |
|||
| msg122355 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2010年11月25日 12:11 | |
A bit of rationale behind the patch. You probably know that the gettext/_ functions serves two roles: Identifying the strings to translate, and retrieving the translation from a catalog.
At strings extraction time, the string in the line
msg = _('unknown parser %r (choices: %s)' % tup)
will be found by xgettext (just checked), so the .pot and .po files will include it. So far, so good.
At runtime however, the gettext function will get "unknown parser 'parserr' (choices: ('some', 'tuple'))" as argument, which isn’t in the translation catalogs. Doing the string interpolation after the gettext call (my patch) avoids this problem.
I will write a test for those two strings.
|
|||
| msg123177 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2010年12月03日 04:40 | |
I’ve started on a test but I’m not sure how to proceed, since I need to use or intercept gettext and compare the error messages of argparse with translated messages to prove that the gettext calls are bogus. There are various ways of using or intercepting gettext from tests, but I have to experiment a bit before I can propose the simplest patch that could possibly work. Exceptionally, I’d like to commit the change as is, and defer the testing for some months, until I can get to #10529. |
|||
| msg123214 - (view) | Author: Steven Bethard (bethard) * (Python committer) | Date: 2010年12月03日 09:30 | |
Yes, I think it's okay to fix this without a test, given that it's a nontrivial amount of work to test gettext stuff. I'd rather have it working now, without tests, than wait until we know how to test stuff with gettext. It's also a pretty minor, obvious fix. Of course, I assume you'll make sure this also merges correctly with your Issue 10528 patch. |
|||
| msg123233 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2010年12月03日 12:35 | |
From the other bug: "If I understand it right, before this patch, people couldn't really supply internationalizations for these calls - they would have had to have a translation for each possible value of, e.g. action.choices or parser.prefix_chars." Exactly. I will commit this evening and refresh the other patch (there is one overlapping change). |
|||
| msg123282 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2010年12月03日 19:26 | |
Fixed in r86984 (py3k) and r86990 (2.7). |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:09 | admin | set | github: 54706 |
| 2010年12月03日 19:26:08 | eric.araujo | set | status: pending -> closed resolution: fixed messages: + msg123282 stage: patch review -> resolved |
| 2010年12月03日 12:43:34 | eric.araujo | link | issue10528 dependencies |
| 2010年12月03日 12:35:52 | eric.araujo | set | status: open -> pending priority: normal -> high messages: + msg123233 |
| 2010年12月03日 09:30:46 | bethard | set | messages: + msg123214 |
| 2010年12月03日 04:40:26 | eric.araujo | set | assignee: eric.araujo messages: + msg123177 |
| 2010年11月25日 12:11:53 | eric.araujo | set | messages: + msg122355 |
| 2010年11月24日 20:17:34 | bethard | set | messages: + msg122301 |
| 2010年11月22日 02:53:40 | belopolsky | set | nosy:
+ belopolsky messages: + msg122076 |
| 2010年11月22日 02:31:24 | eric.araujo | create | |