Skip to content

Commit 9cdf05b

Browse files
AA-Turnerezio-melottihugovk
authored
GH-101986: Support translation for Limited/Unstable API & Stable ABI (#107680)
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com> Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
1 parent 42a86df commit 9cdf05b

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

Doc/tools/extensions/c_annotations.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -126,48 +126,48 @@ def add_annotations(self, app, doctree):
126126
f"Object type mismatch in limited API annotation "
127127
f"for {name}: {record['role']!r} != {objtype!r}")
128128
stable_added = record['added']
129-
message = ' Part of the '
129+
message = sphinx_gettext(' Part of the ')
130130
emph_node = nodes.emphasis(message, message,
131131
classes=['stableabi'])
132132
ref_node = addnodes.pending_xref(
133133
'Stable ABI', refdomain="std", reftarget='stable',
134134
reftype='ref', refexplicit="False")
135135
struct_abi_kind = record['struct_abi_kind']
136136
if struct_abi_kind in {'opaque', 'members'}:
137-
ref_node += nodes.Text('Limited API')
137+
ref_node += nodes.Text(sphinx_gettext('Limited API'))
138138
else:
139-
ref_node += nodes.Text('Stable ABI')
139+
ref_node += nodes.Text(sphinx_gettext('Stable ABI'))
140140
emph_node += ref_node
141141
if struct_abi_kind == 'opaque':
142-
emph_node += nodes.Text(' (as an opaque struct)')
142+
emph_node += nodes.Text(sphinx_gettext(' (as an opaque struct)'))
143143
elif struct_abi_kind == 'full-abi':
144-
emph_node += nodes.Text(' (including all members)')
144+
emph_node += nodes.Text(sphinx_gettext(' (including all members)'))
145145
if record['ifdef_note']:
146146
emph_node += nodes.Text(' ' + record['ifdef_note'])
147147
if stable_added == '3.2':
148148
# Stable ABI was introduced in 3.2.
149149
pass
150150
else:
151-
emph_node += nodes.Text(f' since version {stable_added}')
151+
emph_node += nodes.Text(sphinx_gettext(' since version %s') % stable_added)
152152
emph_node += nodes.Text('.')
153153
if struct_abi_kind == 'members':
154154
emph_node += nodes.Text(
155-
' (Only some members are part of the stable ABI.)')
155+
sphinx_gettext(' (Only some members are part of the stable ABI.)'))
156156
node.insert(0, emph_node)
157157

158158
# Unstable API annotation.
159159
if name.startswith('PyUnstable'):
160160
warn_node = nodes.admonition(
161161
classes=['unstable-c-api', 'warning'])
162-
message = 'This is '
162+
message = sphinx_gettext('This is ')
163163
emph_node = nodes.emphasis(message, message)
164164
ref_node = addnodes.pending_xref(
165165
'Unstable API', refdomain="std",
166166
reftarget='unstable-c-api',
167167
reftype='ref', refexplicit="False")
168-
ref_node += nodes.Text('Unstable API')
168+
ref_node += nodes.Text(sphinx_gettext('Unstable API'))
169169
emph_node += ref_node
170-
emph_node += nodes.Text('. It may change without warning in minor releases.')
170+
emph_node += nodes.Text(sphinx_gettext('. It may change without warning in minor releases.'))
171171
warn_node += emph_node
172172
node.insert(0, warn_node)
173173

Doc/tools/templates/dummy.html

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99

1010
In extensions/c_annotations.py:
1111

12+
{% trans %} Part of the {% endtrans %}
13+
{% trans %}Limited API{% endtrans %}
14+
{% trans %}Stable ABI{% endtrans %}
15+
{% trans %} (as an opaque struct){% endtrans %}
16+
{% trans %} (including all members){% endtrans %}
17+
{% trans %} since version %s{% endtrans %}
18+
{% trans %} (Only some members are part of the stable ABI.){% endtrans %}
19+
{% trans %}This is {% endtrans %}
20+
{% trans %}Unstable API{% endtrans %}
21+
{% trans %}. It may change without warning in minor releases.{% endtrans %}
1222
{% trans %}Return value: Always NULL.{% endtrans %}
1323
{% trans %}Return value: New reference.{% endtrans %}
1424
{% trans %}Return value: Borrowed reference.{% endtrans %}

0 commit comments

Comments
 (0)