Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sphinx-intl update adds python-format flag to messages containing % #58

Open
emlys opened this issue Dec 6, 2021 · 3 comments
Open

Comments

@emlys
Copy link

emlys commented Dec 6, 2021

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 ""
@tk0miya
Copy link
Member

tk0miya commented Dec 7, 2021

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'])>]

@emlys
Copy link
Author

emlys commented Dec 8, 2021

It looks like this is a longstanding issue with babel: python-babel/babel#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?

@tk0miya
Copy link
Member

tk0miya commented Dec 9, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants