summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sphinx/builders/gettext.py4
-rw-r--r--sphinx/util/nodes.py13
2 files changed, 11 insertions, 6 deletions
diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py
index 407f1cd1..fbe8afbb 100644
--- a/sphinx/builders/gettext.py
+++ b/sphinx/builders/gettext.py
@@ -81,10 +81,6 @@ class I18nBuilder(Builder):
catalog = self.catalogs[docname.split(SEP, 1)[0]]
for node, msg in extract_messages(doctree):
- if not node.source:
- continue # built-in message
- if isinstance(node, nodes.literal_block):
- continue
catalog.add(msg, node)
diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py
index a241f574..682ea77b 100644
--- a/sphinx/util/nodes.py
+++ b/sphinx/util/nodes.py
@@ -22,16 +22,25 @@ from sphinx.util.pycompat import class_types
explicit_title_re = re.compile(r'^(.+?)\s*(?<!\x00)<(.*?)>$', re.DOTALL)
caption_ref_re = explicit_title_re # b/w compat alias
-
+IGNORED_NODES = (
+ nodes.Invisible,
+ nodes.Inline,
+ nodes.literal_block,
+ nodes.doctest_block,
+ #XXX there are probably more
+)
def extract_messages(doctree):
"""Extract translatable messages from a document tree."""
for node in doctree.traverse(nodes.TextElement):
- if isinstance(node, (nodes.Invisible, nodes.Inline)):
+ if not node.source:
+ continue # built-in message
+ if isinstance(node, IGNORED_NODES):
continue
# <field_name>orphan</field_name>
# XXX ignore all metadata (== docinfo)
if isinstance(node, nodes.field_name) and node.children[0] == 'orphan':
continue
+
msg = node.rawsource.replace('\n', ' ').strip()
# XXX nodes rendering empty are likely a bug in sphinx.addnodes
if msg: