bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gettext] [PATCH 0/3] Support for Python format strings in braced sy


From: Daiki Ueno
Subject: [bug-gettext] [PATCH 0/3] Support for Python format strings in braced syntax
Date: Fri, 14 Dec 2012 17:47:41 +0900

Hi,

These patches are the first step to support Python's new format
strings, requested a while ago:
<http://lists.gnu.org/archive/html/bug-gettext/2012-04/msg00007.html>

Currently, only braced syntax is supported, which looks like:

  _("foo {bar} baz").format(bar="bar")

As Rodrigo noted in the mail, the format strings should be only valid
when they are used with string.format function.  Unfortunately, the
current xgettext Python backend scans the function calls from left to
right, and so the implementation wouldn't be straightforward.

The current approach looks for dot-keyword after right parenthesis,
and if found, transform the expression into something like:

  .format(_("foo {bar} baz")).format(bar="bar")

and then rescan the token stream.

Since this is my first non-trivial patch for gettext, Any comments
would be appreciated.  Of course, this is not intended for 0.18.2.

Daiki Ueno (3):
  Support for Python braced format strings.
  Document python-brace-format.
  Tests for python-brace-format.

 gettext-tools/doc/gettext.texi                     |  21 ++
 gettext-tools/libgettextpo/ChangeLog               |   4 +
 gettext-tools/libgettextpo/Makefile.am             |   1 +
 gettext-tools/src/ChangeLog                        |  26 +++
 gettext-tools/src/FILES                            |   1 +
 gettext-tools/src/Makefile.am                      |   1 +
 gettext-tools/src/format.c                         |   1 +
 gettext-tools/src/format.h                         |   1 +
 gettext-tools/src/message.c                        |   2 +
 gettext-tools/src/message.h                        |   3 +-
 gettext-tools/src/x-python.c                       | 231 ++++++++++++++++++++-
 gettext-tools/src/x-python.h                       |   2 +-
 gettext-tools/src/xgettext.c                       |   5 +
 gettext-tools/tests/ChangeLog                      |   5 +
 gettext-tools/tests/Makefile.am                    |   4 +-
 .../{format-perl-brace-1 => format-python-brace-1} |  34 ++-
 gettext-tools/tests/xgettext-python-5              |  41 ++++
 17 files changed, 349 insertions(+), 34 deletions(-)
 copy gettext-tools/tests/{format-perl-brace-1 => format-python-brace-1} (53%)
 mode change 100755 => 100644
 create mode 100644 gettext-tools/tests/xgettext-python-5

-- 
1.7.11.7




reply via email to

[Prev in Thread] Current Thread [Next in Thread]