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

Keep "translated" attribute on translated nodes #11502

Merged
merged 2 commits into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Deprecated
Features added
--------------

* #11157: Keep ``translated: True`` attribute on translated nodes.
* #11415: Add a checksum to JavaScript and CSS asset URIs included within
generated HTML, using the CRC32 algorithm.
* :meth:`~sphinx.application.Sphinx.require_sphinx` now allows the version
Expand Down
5 changes: 0 additions & 5 deletions sphinx/transforms/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,6 @@ def apply(self, **kwargs: Any) -> None:
node['raw_entries'] = entries
node['entries'] = new_entries

# remove translated attribute that is used for avoiding double translation.
matcher = NodeMatcher(translated=Any)
for translated in self.document.findall(matcher): # type: nodes.Element
translated.delattr('translated')


class RemoveTranslatableInline(SphinxTransform):
"""
Expand Down
14 changes: 14 additions & 0 deletions tests/test_intl.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,20 @@ def test_gettext_buildr_ignores_only_directive(app):
assert expect_msg.id in [m.id for m in actual if m.id]


@sphinx_intl
def test_node_translated_attribute(app):
app.build()

expected = 23
translated_nodes = 0

doctree = app.env.get_doctree('admonitions')
for node in doctree.traverse():
if hasattr(node, 'get') and node.get('translated', False):
translated_nodes += 1
assert translated_nodes == expected


@sphinx_intl
# use individual shared_result directory to avoid "incompatible doctree" error
@pytest.mark.sphinx(testroot='builder-gettext-dont-rebuild-mo')
Expand Down