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

Issues with PYTHON_FORMAT pattern and the comment blocks #865

Open
hoangduytranuk opened this issue Apr 26, 2022 · 0 comments
Open

Issues with PYTHON_FORMAT pattern and the comment blocks #865

hoangduytranuk opened this issue Apr 26, 2022 · 0 comments

Comments

@hoangduytranuk
Copy link

Overview Description

As mentioned in this bug report Message.locations duplicate unnecessary #10104, I found several problem with the current babel code, specifically with PYTHON_FORMAT pattern, mentioned in the catalog.py and the way that comments are written, as mentioned in the pofile.py.

  1. The PYTHON_FORMAT pattern recognise lines with percentage signs as a python-format and wrongly flagging the message being a python-format, but when loading into editors such as POEdit, the application shown that this is WRONG. I'm translating for Blender.org at the moment and this has caused so much time correcting the file that I ended up taking a look into the Python code and debugging it to find out the reason why. It turned out to be that this pattern, PYTHON_FORMAT, in the catalog.py is currently not smart enough and erroneously creating havoc on the read/write of the PO file. This all started due to the fact I needed to write my own merging tool using Python, rather than relying on the buggy xgettext's msgmerge.
  2. The comment blocks are wrapping with the message undesirably, making changes to the source file when there are NO changes whatsoever has been made by the translator. Very annoying, especially when you are observing changes in the source file.

Steps to Reproduce

  1. Down load the PO translation file from the Blender github (vi.po). This file is the one I'm working on at the moment in my own repository (blender_ui)
  2. Make a simple python read/write this file to a new one, and observe the result:
from sphinx_intl import catalog as c
home = os.environ['HOME']
file_path = os.path.join(home, 'vi.po')
out_file = os.path.join(home, 'test_vi.po')
data = c.load_po(file_path)
c.dump_po(out_file, data, line_width=4096)    # simulate the --no-wrap flag on the msgmerge of xgettext
  1. Open the test_vi.po file in POEdit and you will see right at the top lines being flagged as WRONG use of python-format.
  2. Notice also that comment lines above the msgid are also WRAPPED.

Actual Results

Expected Results

  1. NO Python format ERRORS in the POEdit
  2. Comment lines are NOT wrapped, but they should be sorted for easier observation on changes in the future.

Reproducibility

Everytime.

Additional Information

In the process of debugging and fixing the code myself, I have reported to Sphinx issue github (Message.locations duplicate unnecessary #10104) without realising that each of the module is being separated and managed by different people. So this is the reason why I have to write the bug report, although changes has been made and a pull request has been created, from this fork (hoangduytranuk/babel). Sorry for being abit unwise here due to this is my first time approaching to sphinx source github.

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

1 participant