Skip to content

Commit 5612471

Browse files
gh-98366: use sphinx.locale._ as gettext() in pyspecific.py (GH-98437)
fix(doc-tools): use sphinx.locale._ as gettext() for backward-compatibility in pyspecific.py [why] spinix 5.3 changed locale.translators from a defaultdict(gettext.NullTranslations) to a dict, which leads to failure of pyspecific.py. Use sphinx.locale._ as gettext to fix the issue. (cherry picked from commit d26ee8a) Co-authored-by: Wei-Hsiang (Matt) Wang <[email protected]>
1 parent f7d3b18 commit 5612471

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Doc/tools/extensions/pyspecific.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from sphinx.errors import NoUri
2727
except ImportError:
2828
from sphinx.environment import NoUri
29-
from sphinx.locale import translators
29+
from sphinx.locale import _ as sphinx_gettext
3030
from sphinx.util import status_iterator, logging
3131
from sphinx.util.nodes import split_explicit_title
3232
from sphinx.writers.text import TextWriter, TextTranslator
@@ -109,7 +109,7 @@ class ImplementationDetail(Directive):
109109
def run(self):
110110
self.assert_has_content()
111111
pnode = nodes.compound(classes=['impl-detail'])
112-
label = translators['sphinx'].gettext(self.label_text)
112+
label = sphinx_gettext(self.label_text)
113113
content = self.content
114114
add_text = nodes.strong(label, label)
115115
self.state.nested_parse(content, self.content_offset, pnode)
@@ -203,7 +203,7 @@ def run(self):
203203
else:
204204
args = []
205205

206-
label = translators['sphinx'].gettext(self._label[min(2, len(args))])
206+
label = sphinx_gettext(self._label[min(2, len(args))])
207207
text = label.format(name="``{}``".format(name),
208208
args=", ".join("``{}``".format(a) for a in args if a))
209209

@@ -382,7 +382,7 @@ def run(self):
382382
else:
383383
label = self._removed_label
384384

385-
label = translators['sphinx'].gettext(label)
385+
label = sphinx_gettext(label)
386386
text = label.format(deprecated=self.arguments[0], removed=self.arguments[1])
387387
if len(self.arguments) == 3:
388388
inodes, messages = self.state.inline_text(self.arguments[2],

0 commit comments

Comments
 (0)