sphinx-intl
sphinx-intl copied to clipboard
sphinx-intl update adds python-format flag to messages containing %
Given a POT file with a message that contains a %
, sphinx-intl update
will produce a PO file where that message has an added #, python-format
flag. That flag indicates that the message is a python format string, but all sphinx-intl
messages should come from RST.
Example POT file:
# pot_dir/test.pot
msgid ""
msgstr ""
msgid "the % of change in sediment"
msgstr ""
Produces this PO file:
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-12-06 15:01-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"
#, python-format
msgid "the % of change in sediment"
msgstr ""
It seems babel library adds the "python-format" flag when reading the message catalog from a pot file. I'm not sure what is happened inside babel...
$ python
Python 3.7.12 (default, Oct 5 2021, 14:06:57)
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from babel.messages.pofile import read_po
>>> catalog = read_po(open('test.pot'))
>>> list(catalog)
[<Message '' (flags: [])>, <Message 'the % of change in sediment' (flags: ['python-format'])>]
It looks like this is a longstanding issue with babel: https://github.com/python-babel/babel/issues/35 that might not get solved anytime soon. In the meantime, would it make sense for sphinx-intl
to filter out all python-format
flags?
Thank you for the pointer.
In the meantime, would it make sense for sphinx-intl to filter out all python-format flags?
Sounds good. Could you make a pull request, please? Then, I'll merge it soon.