bpo-32087: Doc: Make "deprecated-removed" directive translatable (GH… · python/cpython@dd52d5c
@@ -196,19 +196,20 @@ class DeprecatedRemoved(Directive):
196196final_argument_whitespace = True
197197option_spec = {}
198198199-_label = 'Deprecated since version %s, will be removed in version %s'
199+_label = 'Deprecated since version {deprecated}, will be removed in version {removed}'
200200201201def run(self):
202202node = addnodes.versionmodified()
203203node.document = self.state.document
204204node['type'] = 'deprecated-removed'
205205version = (self.arguments[0], self.arguments[1])
206206node['version'] = version
207-text = self._label % version
207+label = translators['sphinx'].gettext(self._label)
208+text = label.format(deprecated=self.arguments[0], removed=self.arguments[1])
208209if len(self.arguments) == 3:
209210inodes, messages = self.state.inline_text(self.arguments[2],
210211self.lineno+1)
211-para = nodes.paragraph(self.arguments[2], '', *inodes)
212+para = nodes.paragraph(self.arguments[2], '', *inodes, translatable=False)
212213node.append(para)
213214else:
214215messages = []
@@ -220,13 +221,14 @@ def run(self):
220221content.source = node[0].source
221222content.line = node[0].line
222223content += node[0].children
223-node[0].replace_self(nodes.paragraph('', '', content))
224+node[0].replace_self(nodes.paragraph('', '', content, translatable=False))
224225node[0].insert(0, nodes.inline('', '%s: ' % text,
225226classes=['versionmodified']))
226227else:
227228para = nodes.paragraph('', '',
228229nodes.inline('', '%s.' % text,
229-classes=['versionmodified']))
230+classes=['versionmodified']),
231+translatable=False)
230232node.append(para)
231233env = self.state.document.settings.env
232234env.note_versionchange('deprecated', version[0], node, self.lineno)