[Python-ideas] Gettext syntax (was Re: Allow "assigning" to ...)

Barry Warsaw barry at python.org
Thu Feb 12 17:09:29 CET 2015


On Feb 11, 2015, at 10:33 PM, Terry Reedy wrote:

>A possible solution would be to give 3.x str a __pos__ or __neg__ method, so
>+'python' or -'python' would mean the translation of 'python' (the snake).
>This would be even *less* intrusive and easier to write than _('python').

This is really unnecessary.  These days, I believe standard GNU xgettext can
parse Python code and can be told to use an alternative marker function.
Tools/i18n/pygettext.py certainly can.

Aside from all that, IIRC pygettext (and maybe xgettext) will only recognize
underscore function calls that take exactly one string.  That doesn't help the
module global collision issue, but oh well.

I might as well use this opportunity to plug my flufl.i18n package:

http://pythonhosted.org/flufl.i18n/

It provides a nice, higher level API for doing i18n.  It also does not install
_ into globals by default.

(FWIW, the reason why stdlib gettext installs by default is for ease of use.
People preferred to do the i18n setup in their main module and then just have
that name automatically available everywhere else.  I'm not defending that,
just pointing out the history of this particular baggage.)

Cheers,
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150212/9c820219/attachment-0001.sig>


More information about the Python-ideas mailing list