-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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.locations duplicate unnecessary #10104
Comments
Just to add to the part of the solution. The
in the init method of gettext.py is NOT enough. The
needed to have this as well:
The reason being is that there are location lines includes the working directory in the front part of it. This makes the instances of 'relative path' unique while processing, and being duplicated on the output. The correction (computing relative path) above corrected the problem of duplications. The line causing the problem is with ID:
|
I would like to add a further observation on this bug report. When dumping out PO file's content, especially using 'line_width=' parameter and passing in something like 4096 (a very long line, to force the --no-wrap effects from msgmerge of gettext), I found that the locations are ALSO wrapped. This is, to my observation, wrong. I know some of the locations lines are 'joined' when using 'msgmerge --no-wrap' but this happens, to me, as a result of a bug in the msgmerge implementation, as there are only a few instances in the PO output file where 'locations' are joined by a space. This has the effect creating a DIFF entry when submitting changes to repository, when infact, NOTHING has been changed. The effect creating unnecessary frustrations for code reviewers and an absolute waste of time. I suggest the following modifications in the sphinx's code in the sphinx's code file:
Next, at times, PO messages should be able to re-order in a sorted manner, for easier to trace the messages. There is a built in capability to sort but the 'dump_po' interface does not currently providing a passing mechanism for an option to sort. I suggest the interface of 'dump_po' to change to the following in the file:
|
Good point. Could you send a pull request, please? Note: I guess the main reason for this trouble is some feature (or extension) does not store the line number for the each message. So it would be better to fix it to know where the message is used. |
Hi, Thank you for the suggestion creating pull request. I had the intention of forking the sphinx but not yet know where the repository for babel.messages is. Can you tell me please? By the way, in the past I posted a bug report mentioning the PYTHON_FORMAT problem, in that this re.Pattern causing the problem in recognizing this part "%50 'one letter'" (diouxXeEfFgGcrs%) as an ACCEPTABLE pattern, thus causing the flag "python_format" in the Message class to set, and the Catalog.dump_po will insert a "#, python-format" in the comment section of the message, causing applications such as PoEdit to flag up as a WRONG format for "python-format". The trick is to insert a look behind clause in the PYTHON_FORMAT pattern, as an example here: The old:
The corrected one:
The reason I mentioned here is to have at least a record of what is problem, just in case.
as you can spot the part %28c is causing the flag to set. More testing on this pattern is required. I don't know if the insertion of a look ahead at the end will be sufficient enough to solve this problem, on testing alone with this string, it appears to work. This is my temporal solution:
Update: This appears to work:
|
While debugging and working out changes in the code, I have noticed the style and programming scheme, especially to Message and Catalog classes. I would suggest the following modifications if possible:
This class separation will allow easier code maintenance and expansions. The current code, as I was debugging through, making changes so difficult and many potential 'catch you' unaware hazards can be found. |
|
…ner and Takeshi Komiya: - Added the class variable 'builder' to Catalog class, so any instances of Catalog can access the information within the builder, including things such as app, config, srcdir, outdir etc.. see MessageCatalogBuilder for details. - Initialise this Catalog.builder as the instance of MessageCatalogBuilder is created, ie. in the init() - As Message class is created, list of locations passing to it will be made singular, using set(), sorted alphabetically for easier searching and identifying origins where the message can be found. - source dir is used within the __iter__ of the Catalog, using sphinx.util.osutil.relpath, for safer functionality, to work out the relative path for each location entry.
… file When 3rd party extension does not provide line number for each message, duplicated locations are output to pot file unexpectedly. This filters duplicated locations before generationg pot file.
… file When 3rd party extension does not provide line number for each message, duplicated locations are output to pot file unexpectedly. This filters duplicated locations before generationg pot file.
… file When 3rd party extension does not provide line number for each message, duplicated locations are output to pot file unexpectedly. This filters duplicated locations before generationg pot file.
… file When 3rd party extension does not provide line number for each message, duplicated locations are output to pot file unexpectedly. This filters duplicated locations before generationg pot file.
…ions Fix #10104: gettext: Duplicated locations are output to pot file
Describe the bug
When running
make clean; make gettext
there are times the list of locations is duplicated unnecessarily, example:
or
as shown in this screen viewing of the 'pot' file result:
After debugging a little, the problem appeared to be in the file:
sphinx/builders/gettext.py
in the 'init' method.
My simple solution is this:
Note, this solution will probably needed to be in the
babel.messages.pofile.PoFileParser._process_comment()
and in the
babel.messages.catalog.Message.__init__()
as well.
How to Reproduce
Follow instructions on this page
Contribute Documentation
which comprises of sections for installing dependencies, download sources.
then load the file:
build/gettext/blender_manual.pot
into an editor and search for
#: ../../manual/modeling/hair.rst:0
and you will see repeated locations appear there. The message id is:
Expected behavior
There should only be ONE instance of
build/gettext/blender_manual.pot
and there are NO duplications of other locations.
Your project
https://github.com/hoangduytran/blender_ui
Screenshots
No response
OS
MacOS Catalina 10.15.7
Python version
3.9
Sphinx version
4.1.1
Sphinx extensions
No response
Extra tools
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: