diff options
author | INADA Naoki <methane@users.noreply.github.com> | 2017-03-08 10:07:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-08 10:07:13 (GMT) |
commit | c351ce6a2c923c5016e48ecbf7b1e4833031d154 (patch) | |
tree | 6f57296a50b7b4f81562ad29e1c2d186701d4d60 /Doc | |
parent | c45cd167d403d7d98078d5fc4a37b16195dc7a35 (diff) | |
download | cpython-c351ce6a2c923c5016e48ecbf7b1e4833031d154.zip cpython-c351ce6a2c923c5016e48ecbf7b1e4833031d154.tar.gz cpython-c351ce6a2c923c5016e48ecbf7b1e4833031d154.tar.bz2 |
bpo-28331: fix impl-detail label is removed when content is translated. (GH-195)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/tools/extensions/pyspecific.py | 14 | ||||
-rw-r--r-- | Doc/tools/templates/dummy.html | 6 |
2 files changed, 18 insertions, 2 deletions
diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index 4d4fb8f..1b91259 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -21,6 +21,7 @@ from docutils import nodes, utils from sphinx import addnodes from sphinx.builders import Builder +from sphinx.locale import translators from sphinx.util.nodes import split_explicit_title from sphinx.util.compat import Directive from sphinx.writers.html import HTMLTranslator @@ -103,16 +104,25 @@ class ImplementationDetail(Directive): optional_arguments = 1 final_argument_whitespace = True + # This text is copied to templates/dummy.html + label_text = 'CPython implementation detail:' + def run(self): pnode = nodes.compound(classes=['impl-detail']) + label = translators['sphinx'].gettext(self.label_text) content = self.content - add_text = nodes.strong('CPython implementation detail:', - 'CPython implementation detail:') + add_text = nodes.strong(label, label) if self.arguments: n, m = self.state.inline_text(self.arguments[0], self.lineno) pnode.append(nodes.paragraph('', '', *(n + m))) self.state.nested_parse(content, self.content_offset, pnode) if pnode.children and isinstance(pnode[0], nodes.paragraph): + content = nodes.inline(pnode[0].rawsource, translatable=True) + content.source = pnode[0].source + content.line = pnode[0].line + content += pnode[0].children + pnode[0].replace_self(nodes.paragraph('', '', content, + translatable=False)) pnode[0].insert(0, add_text) pnode[0].insert(1, nodes.Text(' ')) else: diff --git a/Doc/tools/templates/dummy.html b/Doc/tools/templates/dummy.html new file mode 100644 index 0000000..6e43be2 --- /dev/null +++ b/Doc/tools/templates/dummy.html @@ -0,0 +1,6 @@ +This file is not an actual template, but used to add some +texts in extensions to sphinx.pot file. + +In extensions/pyspecific.py: + +{% trans %}CPython implementation detail:{% endtrans %} |