[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gettext] Bug#668226: gettext: Support the new style Python format s
From: |
Santiago Vila |
Subject: |
[bug-gettext] Bug#668226: gettext: Support the new style Python format strings (fwd) |
Date: |
Tue, 1 May 2012 15:00:31 +0200 (CEST) |
User-agent: |
Alpine 2.02 (DEB 1266 2009-07-14) |
Hello.
Received this from the Debian bug system:
---------- Forwarded message ----------
From: "Rodrigo Silva (MestreLion)" <address@hidden>
To: Debian Bug Tracking System <address@hidden>
Date: Mon, 09 Apr 2012 18:58:44 -0300
Subject: Bug#668226: gettext: Support the new style Python format strings
Package: gettext
Version: 0.18.1.1-1ubuntu2
Severity: normal
Tags: upstream
I've stumbled on this issue recently, and while searching if this was
already reported somewhere, I've found upstream bug #30854 in Savannah. Looks
like it wasn't forwarded to neither the old nor the new bug mailing list,
so I'll do it now, make his words mine, and add a few comments on my own:
Mon 23 Aug 2010 05:10:05 PM GMT, original submission by David Planella
https://savannah.gnu.org/bugs/index.php?30854
---------------
Currently the gettext tools support only the old Python string format for
substitutions, that is, %s or %(variable)s type strings.
Python standards PEP 0292 [1] and PEP 3101 [2] recommend the use of $foo
and {foo} strings. More and more Python applications migrate to this new
syntax, and it would make sense for the gettext tools to support it.
The ones I can think, off the top of my head:
xgettext to extract {foo} and $foo strings from Python files and mark
them as python-format in the .pot templates
msgmerge -c to validate those
[1] http://www.python.org/dev/peps/pep-0292/
[2] http://www.python.org/dev/peps/pep-3101/
-----------------
I think he means msgfmt -c, since AFAIK there's no msgmerge -c
A few remarks on my own:
The 3 formats currently co-exist in Python 2:
%(foo)s is used by the % operator, as in "%(foo)s" % {'foo':bar}
{foo} is used by the str.format() method and format() builtin,
as in "{foo}".format(foo=bar) or format("{foo}",foo=bar)
$foo is used by the Template class, as in "$foo".Template(foo=bar)
The % format is deprecated in Python 3, and, while still widely used in
Python 2, its usage for new code is discouraged. format() is the new
standard. See http://docs.python.org/library/stdtypes.html#str.format
That said, I urge gettext to support at least the new format() syntax. If
it's not possible to support 3 different syntax rules simultaneously, at
least give Python users a way to choose one of the sets, using xgettext's
--flag for example
[...]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bug-gettext] Bug#668226: gettext: Support the new style Python format strings (fwd),
Santiago Vila <=