Skip to content

Commit 0febc05

Browse files
cocoatomomethane
authored andcommitted
bpo-32087: Doc: Make "deprecated-removed" directive translatable (GH-4473)
1 parent 58a1096 commit 0febc05

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Doc/tools/extensions/pyspecific.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,20 @@ class DeprecatedRemoved(Directive):
196196
final_argument_whitespace = True
197197
option_spec = {}
198198

199-
_label = 'Deprecated since version %s, will be removed in version %s'
199+
_label = 'Deprecated since version {deprecated}, will be removed in version {removed}'
200200

201201
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)

Doc/tools/templates/dummy.html

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
In extensions/pyspecific.py:
55

66
{% trans %}CPython implementation detail:{% endtrans %}
7+
{% trans %}Deprecated since version {deprecated}, will be removed in version {removed}{% endtrans %}

0 commit comments

Comments
 (0)