Skip to content

Commit

Permalink
Add gettext support to tools/extensions/c_annotations.py (#101989)
Browse files Browse the repository at this point in the history
  • Loading branch information
remilapeyre authored Mar 6, 2023
1 parent f105fe4 commit d959bcd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Doc/tools/extensions/c_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -168,11 +169,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']))


Expand Down
5 changes: 5 additions & 0 deletions Doc/tools/templates/dummy.html
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit d959bcd

Please sign in to comment.