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

Message class wrongly added "python-format" to flags #9959

Closed
hoangduytranuk opened this issue Dec 11, 2021 · 1 comment
Closed

Message class wrongly added "python-format" to flags #9959

hoangduytranuk opened this issue Dec 11, 2021 · 1 comment

Comments

@hoangduytranuk
Copy link

Describe the bug

I am using version 3.5.4. I often use

from sphinx_intl import catalog as c

then use:

msg_data = c.load_po(self.po_path)

and do some processing on my translation (PO, POT) files, and output the result using:

c.dump_po(self.opo_path, msg_data)

the routine creating Message in

babel/messages/catalog.py

is called to create a new Message and it's wrongly guess the 'python_format' for messages containing '%' in the id's body. The use of '%' DOESN'T ALWAYS signify the '%s' etc.. Many times it's used to signify percentages, as in '%20', for example. This caused the 'poedit' editor to fail the validation (CORRECTLY so) for the message.

I haven't debug to find out where the

self.python_format

in the init method of the Messsage is switched to True yet, but this is definitely wrong.

How to Reproduce

$ git clone https://github.com/.../some_project
$ cd some_project
$ pip install -r requirements.txt
$ cd docs
$ make html SPHINXOPTS="-D language=de"
$ # open _build/html/index and see bla bla

Create a po file with a message that uses '%' as percentage in it, such as:

msgid "Build proxy resolution 100% of the original footage dimension"
msgstr ""

then use:

import os
from sphinx_intl import catalog as c

home = os.environ['HOME']
in_po_path = os.path.join(home, 'test_file.po')
out_po_path = os.path.join(home, 'test_out_file.po'

msg_data = c.load_po(in_po_path)
c.dump_po(out_po_path, msg_data)

You shall see the output entry above containing a python-format flag:

#, python-format
msgid "Build proxy resolution 100% of the original footage dimension"
msgstr ""

Expected behavior

Only insert 'python-format' for '%s' or '%d' (as a space holder for the variables)

Your project

https://github.com/hoangduytran/blender_ui

Screenshots

No response

OS

Mac Catalina 10.15.7

Python version

3.8

Sphinx version

3.5.4

Sphinx extensions

No response

Extra tools

https://poedit.net/download

Additional context

No response

@tk0miya
Copy link
Member

tk0miya commented Dec 16, 2021

Thank you for reporting. This is the same as sphinx-doc/sphinx-intl#58. Closing.

@tk0miya tk0miya closed this as completed Dec 16, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants