- Sponsor
-
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
fix #4938: i18n doesn't handle node.title correctly #4939
Conversation
Codecov Report
@@ Coverage Diff @@
## 1.7 #4939 +/- ##
==========================================
+ Coverage 81.96% 81.99% +0.03%
==========================================
Files 282 287 +5
Lines 37594 37960 +366
Branches 5829 5893 +64
==========================================
+ Hits 30813 31125 +312
- Misses 5477 5523 +46
- Partials 1304 1312 +8
Continue to review full report at Codecov.
|
# see: http://docutils.sourceforge.net/docs/ref/doctree.html#structural-subelements | ||
if isinstance(node, nodes.title): | ||
# This generates: <section ...><title>msgstr</title></section> | ||
msgstr = msgstr + '\n' + '-' * len(msgstr) * 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this code is good. I should refactor this sphinx.transform.i18n
module later.
if isinstance(node, nodes.title) and node.source is None: | ||
# Uncomment these lines after merging into master(1.8) | ||
# logger.debug('[i18n] PATCH: %r to have source: %s', | ||
# get_full_module_name(node), repr_domxml(node)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment lines will uncomment after merging master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits
sphinx/util/nodes.py
Outdated
@@ -132,6 +137,11 @@ def is_translatable(node): | |||
META_TYPE_NODES = ( | |||
addnodes.meta, | |||
) | |||
ALLOWED_TRANSLATED_NODES = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is difference from translatable
nodes?
On i18n transform, it is described as following:
# ignore block markups
if not isinstance(patch, ALLOWED_TRANSLATED_NODES):
continue # skip
Are these same meaning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not same.
When msgstr
in po files contain block markup, if not isinstance(patch, ALLOWED_TRANSLATED_NODES):
ignore such translations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it is confusable. Could you rename this please to more appropriate name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about defining it by naming rather than listing node classes in the code of i18n.py
. So, I named ALLOWED_TRANSLATED_NODES
to them, but this was not a property of being given a single name.
The nodes.title that added this time is a hacky code to handle in pair with the processing in i18n.py
.
I'll revert this part and add a comment for each node classes.
I'll merge this after test passing |
Feature or Bugfix
Purpose
make gettext
generates msgid for title oftopic
directive andcontents
directivemake html
with i18n catalog apply translated message even if msgid starts with1.
Detail
see #4938