bug-gettext
[Top][All Lists]
Advanced

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

[bug #64359] xgettext: "python-format" error in "Advanced String Formatt


From: Christian Buhtz
Subject: [bug #64359] xgettext: "python-format" error in "Advanced String Formatting"
Date: Tue, 27 Jun 2023 10:57:06 -0400 (EDT)

URL:
  <https://savannah.gnu.org/bugs/?64359>

                 Summary: xgettext: "python-format" error in "Advanced String
Formatting"
                   Group: GNU gettext
               Submitter: buhtz
               Submitted: Tue 27 Jun 2023 04:57:04 PM CEST
                Category: Translator tools
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Tue 27 Jun 2023 04:57:04 PM CEST By: Christian Buhtz <buhtz>
This was reported first at
https://github.com/WeblateOrg/weblate/issues/9449

Python has several ways to format strings. It seems that xgettext is not able
to differentiate between them.

See this example source.py file

#!/usr/bin/env python3
import gettext
_ = gettext.gettext

val = '15'
print(_('Trying to keep min {perc}% free inodes').format(perc=val))

According to PEP 3101 about "Advanced String Formatting" there is no need to
escape the % sign. It is a usual character here.

Doing "xgettext source.py" results in a "messages.po" like this (header
snipped).

#: source.py:6
#, python-format, python-brace-format
msgid "Trying to keep min {perc}% free inodes"
msgstr ""

The problem is that xgettext thinks that "% f" is a format string and should
be "%f". Which is not the case.

The version used is "xgettext (GNU gettext-tools) 0.21 " from Debian
repository.







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?64359>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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