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

This commit is contained in:
Rémi Lapeyre 2023-03-06 22:20:52 +01:00 committed by GitHub
parent f105fe4f0a
commit d959bcd4a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -24,6 +24,7 @@ from docutils import nodes
from docutils.parsers.rst import directives from docutils.parsers.rst import directives
from docutils.parsers.rst import Directive from docutils.parsers.rst import Directive
from docutils.statemachine import StringList from docutils.statemachine import StringList
from sphinx.locale import _ as sphinx_gettext
import csv import csv
from sphinx import addnodes from sphinx import addnodes
@ -168,11 +169,11 @@ class Annotations:
elif not entry.result_type.endswith("Object*"): elif not entry.result_type.endswith("Object*"):
continue continue
if entry.result_refs is None: if entry.result_refs is None:
rc = 'Return value: Always NULL.' rc = sphinx_gettext('Return value: Always NULL.')
elif entry.result_refs: elif entry.result_refs:
rc = 'Return value: New reference.' rc = sphinx_gettext('Return value: New reference.')
else: else:
rc = 'Return value: Borrowed reference.' rc = sphinx_gettext('Return value: Borrowed reference.')
node.insert(0, nodes.emphasis(rc, rc, classes=['refcount'])) node.insert(0, nodes.emphasis(rc, rc, classes=['refcount']))

View File

@ -7,6 +7,11 @@ In extensions/pyspecific.py:
{% trans %}Deprecated since version {deprecated}, will be removed in version {removed}{% endtrans %} {% trans %}Deprecated since version {deprecated}, will be removed in version {removed}{% endtrans %}
{% trans %}Deprecated since version {deprecated}, 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: In docsbuild-scripts, when rewriting indexsidebar.html with actual versions: