bpo-32087: Doc: Make "deprecated-removed" directive translatable (GH… · python/cpython@dd52d5c

@@ -196,19 +196,20 @@ class DeprecatedRemoved(Directive):

196196

final_argument_whitespace = True

197197

option_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}'

200200201201

def run(self):

202202

node = addnodes.versionmodified()

203203

node.document = self.state.document

204204

node['type'] = 'deprecated-removed'

205205

version = (self.arguments[0], self.arguments[1])

206206

node['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])

208209

if len(self.arguments) == 3:

209210

inodes, messages = self.state.inline_text(self.arguments[2],

210211

self.lineno+1)

211-

para = nodes.paragraph(self.arguments[2], '', *inodes)

212+

para = nodes.paragraph(self.arguments[2], '', *inodes, translatable=False)

212213

node.append(para)

213214

else:

214215

messages = []

@@ -220,13 +221,14 @@ def run(self):

220221

content.source = node[0].source

221222

content.line = node[0].line

222223

content += node[0].children

223-

node[0].replace_self(nodes.paragraph('', '', content))

224+

node[0].replace_self(nodes.paragraph('', '', content, translatable=False))

224225

node[0].insert(0, nodes.inline('', '%s: ' % text,

225226

classes=['versionmodified']))

226227

else:

227228

para = nodes.paragraph('', '',

228229

nodes.inline('', '%s.' % text,

229-

classes=['versionmodified']))

230+

classes=['versionmodified']),

231+

translatable=False)

230232

node.append(para)

231233

env = self.state.document.settings.env

232234

env.note_versionchange('deprecated', version[0], node, self.lineno)