You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found a similar issue #4938 was discussed in the past. It was fixed but I feel it is related to this one.
According to my local debugging, two failing titles from the above example, are not extracted because they have no node.source and are excluded in sphinx.util.nodes.is_translatable(), at this if check
if isinstance(node, nodes.TextElement):
if not node.source:
logger.debug('[i18n] SKIP %r because no node.source: %s',
get_full_module_name(node), repr_domxml(node))
because they are not "patched" with the source code line number in apply_source_workaround(). If I'm logging patching and skipping, they of affected title, it looks very chaotic - in large project, few times patched, few times skipped, and finally skipped forever.
In test-intl and 4. Topic Title:
$ cd tests/roots/test-intl
$ sphinx-build -vvv -b gettext . _build/gettext | grep '4. Topic Title'
[i18n] PATCH: 'docutils.nodes.title' to have source: <title>4. Topic Title</title>
[i18n] SKIP 'docutils.nodes.title' because no node.source: <title>4. Topic Title</title>
[i18n] SKIP 'docutils.nodes.title' because no node.source: <title>4. Topic Title</title>
But title 5. Topic Title is only skipped once:
sphinx-build -vvv -b gettext . _build/gettext | grep '5. Topic Title'
[i18n] SKIP 'docutils.nodes.title' because no node.source: <title>5. Topic Title</title>
The text was updated successfully, but these errors were encountered:
Note: It seems docutils does not fill the topic node with the source info when the topic directive has a bullet list.
from docutils.core import publish_doctree
# topic directive with a paragraph
s = """
.. topic:: 5. Topic Title
Paragraph
"""
(topic,) = publish_doctree(s)
print(topic.source, topic.line)
# topic directive with a bullet list
s = """
.. topic:: 5. Topic Title
- Bullet List Item
"""
(topic,) = publish_doctree(s)
print(topic.source, topic.line)
$ python test.py
<string> None
None None
tk0miya
added a commit
to tk0miya/sphinx
that referenced
this issue
Dec 9, 2021
… be translatable
It seems docutils does not fill the topic node with the source info when
a topic directive has a bullet list. As a workaround, This fills the
source info of them.
Describe the bug
Titles of block elements are not properly picked up by "make gettext" if the block body contains a bullet list or paragraph followed by a bullet list.
I discovered it and test it with topic block, maybe other admonition-style blocks are suffering the issue too.
All titles in the following topic are extracted to POT:
but the two titles will NOT be added to POT:
Very strange.
How to Reproduce
In my forked repo, I extended
test_gettext_topic
test to demonstrate it (and to fail at this moment). Please see liborjelinek@0f7eda4.and finally failing test
Expected behavior
In the above example, msgid for "4. Topic Title" and "5. Topic Title" created in POT.
Your project
https://github.com/mattdocumatt/sphinx/tree/i18n-doesnt-extract-some-titles
Screenshots
No response
OS
macOS
Python version
3.8.2
Sphinx version
latest
Sphinx extensions
No response
Extra tools
No response
Additional context
I found a similar issue #4938 was discussed in the past. It was fixed but I feel it is related to this one.
According to my local debugging, two failing titles from the above example, are not extracted because they have no
node.source
and are excluded insphinx.util.nodes.is_translatable()
, at this if checkbecause they are not "patched" with the source code line number in
apply_source_workaround()
. If I'm logging patching and skipping, they of affected title, it looks very chaotic - in large project, few times patched, few times skipped, and finally skipped forever.In test-intl and
4. Topic Title
:But title
5. Topic Title
is only skipped once:The text was updated successfully, but these errors were encountered: