msg64675 - (view) |
Author: Pierre Metras (genepi) |
Date: 2008-03-29 02:10 |
Please add support for pgettext(msgctxt, msgid) and variants (dpgettext,
dcpgettext...) in the gettext module.
I will not rephrase the justification for these functions and why
contexts are essential for good localization:
http://www.gnu.org/software/gettext/manual/gettext.html#Contexts
|
msg64685 - (view) |
Author: Martin v. Löwis (loewis) * |
Date: 2008-03-29 08:38 |
Would you like to work on a patch?
|
msg65526 - (view) |
Author: Franz Glasner (franz_glasner) |
Date: 2008-04-15 20:17 |
I have written a patch against the current Python trunk's gettext to
add support for pgettext and friends (upgettext, npgettext, unpgettext,
...).
I have also changed Tools/i18n/msgfmt.py to recognize the "msgctxt" keyword.
Some new unittests for dgettext and lgettext and variants are also included.
If the patch will be accepted then someone should drop a message to the
maintainers of GNU gettext to add the new functions as default keywords
for xgettext. Right now you have to call xgettext with
"--keyword=pgettext:1c,2" to extract messages with context.
Tools/i18n/pygettext.py does currently not handle context variants.
|
msg79609 - (view) |
Author: STINNER Victor (vstinner) * |
Date: 2009-01-11 18:57 |
I don't see any change in Modules/_localemodule.c: you reimplemented
pgettext() in pure Python. Why no reusing existing pgettext() function
(at least when it's present)?
|
msg79610 - (view) |
Author: Martin v. Löwis (loewis) * |
Date: 2009-01-11 19:00 |
The gettext module is intentionally written in pure Python; it should
stay that way. Whether or not the _locale module should also grow
support for pgettext is a different issue.
|
msg90338 - (view) |
Author: David Schnur (dns) |
Date: 2009-07-09 18:14 |
I came across this ticket while looking for alternatives to Python's
gettext, since I need msgctx support. It seems a patch was supplied for
this a while back. I have never contributed to Python, and am not
familiar with your release process, but is there anything preventing its
inclusion? It would be very convenient to have this in a release version.
|
msg90339 - (view) |
Author: Martin v. Löwis (loewis) * |
Date: 2009-07-09 18:31 |
Only my lack of time prevents inclusion.
|
msg91472 - (view) |
Author: Mitar (mitar) * |
Date: 2009-08-11 09:56 |
I would just like to add that I am also looking forwards to this feature.
|
msg92796 - (view) |
Author: Niklas Hambüchen (nh2) |
Date: 2009-09-17 21:19 |
Me too. This makes developing applications with good localizations in
Python really difficult.
|
msg97788 - (view) |
Author: David D Lowe (Flimm) |
Date: 2010-01-14 21:18 |
Same here.
|
msg105126 - (view) |
Author: Olivier Berten (olivier-berten) |
Date: 2010-05-06 06:49 |
Pleeeeeeeaaaaaaaase ;-)
|
msg106121 - (view) |
Author: Bernie H. Innocenti (bernie) |
Date: 2010-05-20 00:07 |
While we're waiting for this patch to be upstreamed, what's the best way to emulate this functionality with the current gettext module?
I'm looking at the patch and it seems that code similar to this might work?
def pgettext(ctx, msg):
return gettext(ctx + "\x04" + msg)
|
msg106132 - (view) |
Author: Wil Clouser (clouserw) |
Date: 2010-05-20 04:47 |
Yes. You can see an in-production implementation at http://github.com/clouserw/tower/blob/master/tower/__init__.py#L51 (I'm overriding ugettext to support an optional context).
|
msg106709 - (view) |
Author: Wichert Akkerman (wichert) |
Date: 2010-05-29 06:39 |
Martin, is there anything we can do to help get this merged? I can really use this as well.
My background here is that currently the complete zope i18n support abuses message ids as a workaround, and the result works but is very painful for translators since the original string is not immediately visible for them.
|
msg107560 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2010-06-11 16:44 |
The patch needs to be updated for the 3.x trunk (py3k branch), since the last 2.x version is already rc.
Everyone, thanks for expressing interest for the development of Python, but posting “me too” messages does not further the discussion, and actually takes time from already busy people. Use cases, patches, reviews and the occasional bump (one is enough) are helpful. :)
|
msg122439 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2010-11-26 05:28 |
I have ported the patch to py3k, without tests errors but with test failures. What is left to do:
1) Carefully assess bytes/str issues. Decide to change the tests or the code.
2) Re-read over the new docs.
3) Exercise the updated msgfmt.py tool, which has no tests.
4) Add support in pygettext.py.
David, Mitar, nh2, David D., Olivier, Bernie, Wil, Wichert: Do you want to help with one of those tasks?
|
msg122446 - (view) |
Author: Wichert Akkerman (wichert) |
Date: 2010-11-26 09:20 |
I can help test changes for python 2.x. The python 3.x ecosystem is at least a year away from becoming interesting for me I'm afraid.
|
msg122482 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2010-11-26 23:13 |
New features don’t go into stable branches.
The patch is also reviewable at http://codereview.appspot.com/3340041
|
msg202189 - (view) |
Author: Neil Hooey (nhooey) |
Date: 2013-11-05 03:13 |
Can someone review the patch and consider its inclusion?
|
msg230537 - (view) |
Author: Wichert Akkerman (wichert) |
Date: 2014-11-03 14:49 |
Bump.
Python 3 is still not on my radar, but I'll happily do a backport for Py2 and drop that on PyPI once this gets resolved.
|
msg234853 - (view) |
Author: Hanno Zulla (Hanno.Zulla) |
Date: 2015-01-27 21:02 |
Can we please get pgettext for Python?
|
msg277652 - (view) |
Author: Antti Haapala (ztane) * |
Date: 2016-09-28 19:05 |
*wow* isn't this in Python 3 yet (I've been using Zope translationstrings lately so I didn't know that pgettext is still not supported).
|
msg302801 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) * |
Date: 2017-09-23 19:25 |
This looks like a nice feature. Éric, could you please create a PR on GitHub?
I think that new l*gettext functions are not needed. They are rather useless in Python 3 (see issue29755).
|
msg306594 - (view) |
Author: Jonathan Schoonhoven (Jonathan Schoonhoven) |
Date: 2017-11-20 22:30 |
Is there anything I can do to help get this into the codebase and out issue purgatory? We're not that far off from the 10 year anniversary of this issue.
|
msg306600 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2017-11-20 23:39 |
The patch would need to be applied on top of the current master to make a pull request. Then, the tasks outlined in that message should be addressed:
https://bugs.python.org/issue2504#msg122439
|
msg317139 - (view) |
Author: Cheryl Sabella (cheryl.sabella) * |
Date: 2018-05-19 21:48 |
Éric,
Was your last comment intended as a todo for yourself or an outline of the steps needed for someone else to move this along (maybe it was a reply to Jonathan Schoonhoven's question)?
If the latter, I'd be happy to try to work on the PR.
Thanks!
|
msg317300 - (view) |
Author: Éric Araujo (eric.araujo) * |
Date: 2018-05-22 15:40 |
It was an answer to «Is there anything I can do to help get this into the codebase»
Feel free to take this on! I’ll try to review.
|
msg318206 - (view) |
Author: Cheryl Sabella (cheryl.sabella) * |
Date: 2018-05-30 20:17 |
I've created a pull request for this based on Éric's patch in 2010. I attempted to incorporate the changes from #29755 into the new functions and tests. I believe these changes take care of items 1 and 2 from msg122439.
I haven't tried to address item 3 in msg122439 yet.
Since this is already a large change, item 4 in msg122439 might be better as its own issue.
|
msg318261 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) * |
Date: 2018-05-31 06:33 |
Do you have a use case for lpgettext() and like?
|
msg318282 - (view) |
Author: Cheryl Sabella (cheryl.sabella) * |
Date: 2018-05-31 10:36 |
No, I didn't have a use case for the l* functions. I included them just as a result of applying the entire patch from 2010. I also didn't know if further discussion was needed before excluding them.
|
msg328643 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) * |
Date: 2018-10-27 05:35 |
l*gettext() functions have been just deprecated in issue33710. Please update the PR and remove new l*gettext() functions.
|
msg329417 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) * |
Date: 2018-11-07 14:12 |
New changeset 637a33b99685fd5d1032670fbe29c7c8a8f0ff63 by Serhiy Storchaka (Cheryl Sabella) in branch 'master':
bpo-2504: Add pgettext() and variants to gettext. (GH-7253)
https://github.com/python/cpython/commit/637a33b99685fd5d1032670fbe29c7c8a8f0ff63
|
msg357389 - (view) |
Author: Eli Schwartz (eschwartz) * |
Date: 2019-11-24 05:01 |
Interestingly enough, the final accepted patch (and the 2010 one) also fixes a bug where gettext.install(..., names='ngettext') would incorrectly work, in violation of the documentation.
I think it would also incorrectly install 'gettext', too...
It used to just check if names.__contains__ is a valid attribute, then check if 'foo' in names, so a dumb string "worked" and even matched more things than it should have.
How I discovered this: I fixed a bug in a python project that stopped working on python 3.8, and had a bit of a head-scratch regarding how it ever worked to begin with: https://github.com/linuxmint/cinnamon/pull/8964
|
|
Date |
User |
Action |
Args |
2022-04-11 14:56:32 | admin | set | github: 46756 |
2019-11-24 05:01:50 | eschwartz | set | nosy:
+ eschwartz messages:
+ msg357389
|
2018-11-07 14:32:50 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: needs patch -> resolved |
2018-11-07 14:12:24 | serhiy.storchaka | set | messages:
+ msg329417 |
2018-10-27 05:35:04 | serhiy.storchaka | set | messages:
+ msg328643 versions:
+ Python 3.8, - Python 3.7 |
2018-05-31 10:36:24 | cheryl.sabella | set | messages:
+ msg318282 |
2018-05-31 06:33:26 | serhiy.storchaka | set | messages:
+ msg318261 |
2018-05-30 20:17:47 | cheryl.sabella | set | messages:
+ msg318206 stage: patch review -> needs patch |
2018-05-30 20:12:59 | cheryl.sabella | set | stage: needs patch -> patch review pull_requests:
+ pull_request6882 |
2018-05-22 15:40:09 | eric.araujo | set | messages:
+ msg317300 |
2018-05-19 21:48:16 | cheryl.sabella | set | nosy:
+ cheryl.sabella messages:
+ msg317139
|
2017-11-20 23:39:34 | eric.araujo | set | assignee: loewis -> messages:
+ msg306600 |
2017-11-20 22:30:57 | Jonathan Schoonhoven | set | nosy:
+ Jonathan Schoonhoven messages:
+ msg306594
|
2017-09-23 19:25:33 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages:
+ msg302801
|
2017-09-19 16:21:59 | eric.araujo | set | keywords:
+ needs review versions:
+ Python 3.7, - Python 3.5 |
2016-11-16 13:44:51 | Tristan.Fisher | set | nosy:
+ Tristan.Fisher
|
2016-09-28 19:05:20 | ztane | set | nosy:
+ ztane messages:
+ msg277652
|
2016-09-28 18:33:20 | Leonid Suprun | set | nosy:
+ Leonid Suprun
|
2015-01-27 21:13:29 | berker.peksag | set | nosy:
+ berker.peksag
|
2015-01-27 21:02:13 | Hanno.Zulla | set | nosy:
+ Hanno.Zulla messages:
+ msg234853
|
2014-11-03 14:56:08 | eric.araujo | set | stage: patch review -> needs patch versions:
- Python 3.2, Python 3.3, Python 3.4, Python 3.6 |
2014-11-03 14:49:41 | wichert | set | messages:
+ msg230537 versions:
+ Python 3.3, Python 3.4, Python 3.5, Python 3.6 |
2013-11-05 03:13:03 | nhooey | set | nosy:
+ nhooey messages:
+ msg202189
|
2011-02-11 17:28:31 | sascha_silbe | set | nosy:
+ sascha_silbe
|
2011-01-31 19:15:02 | bersace | set | nosy:
+ Felix Schwarz
|
2011-01-31 19:14:36 | bersace | set | nosy:
+ bersace
|
2011-01-31 19:14:17 | bersace | set | nosy:
- Felix Schwarz
|
2010-12-26 17:05:45 | Felix Schwarz | set | nosy:
+ Felix Schwarz
|
2010-11-26 23:13:57 | eric.araujo | set | messages:
+ msg122482 |
2010-11-26 09:20:22 | wichert | set | messages:
+ msg122446 |
2010-11-26 05:28:48 | eric.araujo | set | files:
+ pgettext-3.2.diff resolution: accepted -> (no value) messages:
+ msg122439
stage: needs patch -> patch review |
2010-06-29 12:42:28 | eric.araujo | set | resolution: accepted stage: needs patch |
2010-06-15 15:25:41 | nils | set | nosy:
+ nils
|
2010-06-11 16:44:09 | eric.araujo | set | nosy:
+ eric.araujo messages:
+ msg107560
|
2010-05-29 06:39:49 | wichert | set | nosy:
+ wichert messages:
+ msg106709
|
2010-05-20 04:47:21 | clouserw | set | messages:
+ msg106132 |
2010-05-20 00:07:17 | bernie | set | nosy:
+ bernie messages:
+ msg106121
|
2010-05-06 06:56:14 | loewis | set | versions:
+ Python 3.2, - Python 2.6, Python 3.0 |
2010-05-06 06:49:23 | olivier-berten | set | nosy:
+ olivier-berten messages:
+ msg105126
|
2010-01-14 21:18:26 | Flimm | set | nosy:
+ Flimm messages:
+ msg97788
|
2009-12-02 21:29:04 | clouserw | set | nosy:
+ clouserw
|
2009-10-24 19:29:56 | AndrewZiem | set | nosy:
+ AndrewZiem
|
2009-09-20 18:47:00 | cito | set | nosy:
+ cito
|
2009-09-17 21:19:32 | nh2 | set | nosy:
+ nh2 messages:
+ msg92796
|
2009-08-11 09:56:19 | mitar | set | nosy:
+ mitar messages:
+ msg91472
|
2009-07-09 18:31:24 | loewis | set | messages:
+ msg90339 |
2009-07-09 18:14:21 | dns | set | nosy:
+ dns messages:
+ msg90338
|
2009-03-24 23:07:27 | vstinner | set | nosy:
- vstinner
|
2009-01-11 19:00:36 | loewis | set | messages:
+ msg79610 |
2009-01-11 18:57:45 | vstinner | set | nosy:
+ vstinner messages:
+ msg79609 |
2009-01-11 12:25:13 | dwayne | set | nosy:
+ dwayne |
2008-05-03 10:22:28 | bronger | set | nosy:
+ bronger |
2008-04-15 21:17:01 | loewis | set | assignee: loewis |
2008-04-15 20:17:20 | franz_glasner | set | files:
+ gettext-pgettext.patch nosy:
+ franz_glasner keywords:
+ patch messages:
+ msg65526 components:
+ Library (Lib), - Extension Modules |
2008-03-29 08:38:24 | loewis | set | nosy:
+ loewis messages:
+ msg64685 |
2008-03-29 02:10:23 | genepi | create | |