[Python-checkins] Add gettext support to tools/extensions/c_annotations.py (GH-101989)

miss-islington webhook-mailer at python.org
Mon Mar 6 16:53:54 EST 2023


https://github.com/python/cpython/commit/280b975c3f18674eca1dfbed33fc13330535b241
commit: 280b975c3f18674eca1dfbed33fc13330535b241
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2023-03-06T13:53:47-08:00
summary:

Add gettext support to tools/extensions/c_annotations.py (GH-101989)

(cherry picked from commit d959bcd4a0393a120fa12c034de4041037d171c3)

Co-authored-by: Rémi Lapeyre <remi.lapeyre at lenstra.fr>

files:
M Doc/tools/extensions/c_annotations.py
M Doc/tools/templates/dummy.html

diff --git a/Doc/tools/extensions/c_annotations.py b/Doc/tools/extensions/c_annotations.py
index 9defb24a0331..a845ef46c0ba 100644
--- a/Doc/tools/extensions/c_annotations.py
+++ b/Doc/tools/extensions/c_annotations.py
@@ -24,6 +24,7 @@
 from docutils.parsers.rst import directives
 from docutils.parsers.rst import Directive
 from docutils.statemachine import StringList
+from sphinx.locale import _ as sphinx_gettext
 import csv
 
 from sphinx import addnodes
@@ -152,11 +153,11 @@ def add_annotations(self, app, doctree):
             elif not entry.result_type.endswith("Object*"):
                 continue
             if entry.result_refs is None:
-                rc = 'Return value: Always NULL.'
+                rc = sphinx_gettext('Return value: Always NULL.')
             elif entry.result_refs:
-                rc = 'Return value: New reference.'
+                rc = sphinx_gettext('Return value: New reference.')
             else:
-                rc = 'Return value: Borrowed reference.'
+                rc = sphinx_gettext('Return value: Borrowed reference.')
             node.insert(0, nodes.emphasis(rc, rc, classes=['refcount']))
 
 
diff --git a/Doc/tools/templates/dummy.html b/Doc/tools/templates/dummy.html
index 3438b44377fc..bab4aaeb4604 100644
--- a/Doc/tools/templates/dummy.html
+++ b/Doc/tools/templates/dummy.html
@@ -7,6 +7,11 @@
 {% trans %}Deprecated since version {deprecated}, will be removed in version {removed}{% endtrans %}
 {% trans %}Deprecated since version {deprecated}, removed in version {removed}{% endtrans %}
 
+In extensions/c_annotations.py:
+
+{% trans %}Return value: Always NULL.{% endtrans %}
+{% trans %}Return value: New reference.{% endtrans %}
+{% trans %}Return value: Borrowed reference.{% endtrans %}
 
 In docsbuild-scripts, when rewriting indexsidebar.html with actual versions:
 



More information about the Python-checkins mailing list