mirror of
https://github.com/python/cpython.git
synced 2025-08-19 16:20:59 +00:00
[3.11] GH-84435: Make pyspecific directives translatable (GH-19470) (#107682)
GH-84435: Make pyspecific directives translatable (GH-19470)
(cherry picked from commit ecb05e0b98
)
Co-authored-by: cocoatomo <cocoatomo77@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
This commit is contained in:
parent
648d42643e
commit
0aa3b9d76c
1 changed files with 8 additions and 10 deletions
|
@ -103,14 +103,13 @@ class ImplementationDetail(Directive):
|
||||||
final_argument_whitespace = True
|
final_argument_whitespace = True
|
||||||
|
|
||||||
# This text is copied to templates/dummy.html
|
# This text is copied to templates/dummy.html
|
||||||
label_text = 'CPython implementation detail:'
|
label_text = sphinx_gettext('CPython implementation detail:')
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.assert_has_content()
|
self.assert_has_content()
|
||||||
pnode = nodes.compound(classes=['impl-detail'])
|
pnode = nodes.compound(classes=['impl-detail'])
|
||||||
label = sphinx_gettext(self.label_text)
|
|
||||||
content = self.content
|
content = self.content
|
||||||
add_text = nodes.strong(label, label)
|
add_text = nodes.strong(self.label_text, self.label_text)
|
||||||
self.state.nested_parse(content, self.content_offset, pnode)
|
self.state.nested_parse(content, self.content_offset, pnode)
|
||||||
content = nodes.inline(pnode[0].rawsource, translatable=True)
|
content = nodes.inline(pnode[0].rawsource, translatable=True)
|
||||||
content.source = pnode[0].source
|
content.source = pnode[0].source
|
||||||
|
@ -239,9 +238,9 @@ class AuditEvent(Directive):
|
||||||
final_argument_whitespace = True
|
final_argument_whitespace = True
|
||||||
|
|
||||||
_label = [
|
_label = [
|
||||||
"Raises an :ref:`auditing event <auditing>` {name} with no arguments.",
|
sphinx_gettext("Raises an :ref:`auditing event <auditing>` {name} with no arguments."),
|
||||||
"Raises an :ref:`auditing event <auditing>` {name} with argument {args}.",
|
sphinx_gettext("Raises an :ref:`auditing event <auditing>` {name} with argument {args}."),
|
||||||
"Raises an :ref:`auditing event <auditing>` {name} with arguments {args}.",
|
sphinx_gettext("Raises an :ref:`auditing event <auditing>` {name} with arguments {args}."),
|
||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -257,7 +256,7 @@ class AuditEvent(Directive):
|
||||||
else:
|
else:
|
||||||
args = []
|
args = []
|
||||||
|
|
||||||
label = sphinx_gettext(self._label[min(2, len(args))])
|
label = self._label[min(2, len(args))]
|
||||||
text = label.format(name="``{}``".format(name),
|
text = label.format(name="``{}``".format(name),
|
||||||
args=", ".join("``{}``".format(a) for a in args if a))
|
args=", ".join("``{}``".format(a) for a in args if a))
|
||||||
|
|
||||||
|
@ -419,8 +418,8 @@ class DeprecatedRemoved(Directive):
|
||||||
final_argument_whitespace = True
|
final_argument_whitespace = True
|
||||||
option_spec = {}
|
option_spec = {}
|
||||||
|
|
||||||
_deprecated_label = 'Deprecated since version {deprecated}, will be removed in version {removed}'
|
_deprecated_label = sphinx_gettext('Deprecated since version {deprecated}, will be removed in version {removed}')
|
||||||
_removed_label = 'Deprecated since version {deprecated}, removed in version {removed}'
|
_removed_label = sphinx_gettext('Deprecated since version {deprecated}, removed in version {removed}')
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
node = addnodes.versionmodified()
|
node = addnodes.versionmodified()
|
||||||
|
@ -436,7 +435,6 @@ class DeprecatedRemoved(Directive):
|
||||||
else:
|
else:
|
||||||
label = self._removed_label
|
label = self._removed_label
|
||||||
|
|
||||||
label = sphinx_gettext(label)
|
|
||||||
text = label.format(deprecated=self.arguments[0], removed=self.arguments[1])
|
text = label.format(deprecated=self.arguments[0], removed=self.arguments[1])
|
||||||
if len(self.arguments) == 3:
|
if len(self.arguments) == 3:
|
||||||
inodes, messages = self.state.inline_text(self.arguments[2],
|
inodes, messages = self.state.inline_text(self.arguments[2],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue