Skip to content

fix: align cross-reference roles with the English source - #1244

Draft
mattwang44 wants to merge 2 commits into
3.14from
fix/role-consistency
Draft

mattwang44 wants to merge 2 commits into
3.14from
fix/role-consistency

Conversation

@mattwang44

@mattwang44 mattwang44 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Why

13 translated messages use a different role from the one in their msgid. For example the
source says :class:`typing.Union``` and the translation says :data:`typing.Union```.

Five of them render with no link at all — they are broken on the site right now. The
role points at the wrong domain, so the target is never found and the text renders as
plain code instead of a link:

file translation (wrong) source
library/asyncio-eventloop.po ×3 ``:py:const:`socket.SO_REUSEPORT ``` ``:ref:`socket.SO_REUSEPORT ```
whatsnew/3.12.po ×2 ``:const:`Py_TPFLAGS_ITEMS_AT_END``` ``:c:macro:`Py_TPFLAGS_ITEMS_AT_END```
  • socket-unix-constants is a label. :py:const: looks for a Python object with that
    name and finds none. The ~ prefix is dropped as well, because :ref: does not strip a
    module path.
  • Py_TPFLAGS_ITEMS_AT_END and Py_TPFLAGS_IMMUTABLETYPE are C macros. :const: only
    searches the Python domain.

The other eight still resolve, because the Python domain's find_obj() ignores the
object type when the target has no leading dot, so a wrong role still finds the object and
only the rendered CSS class differs (py-data vs py-class). They are corrected for
consistency with the source.

What changed

file translation (wrong) corrected to
library/functools.po :data: :class: typing.Union
library/stdtypes.po ×2 :data: :class: typing.Union
library/asyncio-future.po :func: :meth: concurrent.futures.Future.cancel
tutorial/errors.po :class: :exc: Exception
library/sys.po :attr: :data: sys.builtin_module_names
library/typing.po :func: :ref: overloaded functions <overload>
whatsnew/3.12.po :data: :const: os.PIDFD_NONBLOCK

Only the role token changed in each message; the translated text is otherwise untouched. I
verified this per message: applying the intended substitution to the original string
reproduces the new string exactly, for all 13. msgfmt --check passes on every file.

Background

I found these while testing a fix for
sphinx-doc/sphinx#14162. Sphinx today
compares only the reftarget, which is socket-unix-constants on both sides, so it does
not notice. sphinx-doc/sphinx#14357
compares the domain and role as well, so once that lands all 13 become build warnings.
Better to fix them now.

One more: bugs.po

bugs.rst:105 translates both link names in the same message. When a message contains
more than one translated reference name, Sphinx's fix-up has to guess which original
target each name refers to, and
sphinx-doc/sphinx#14357 deliberately
keeps warning in that case rather than trusting the guess. Naming the targets explicitly
(`譯文 <Python Developer's Guide_>`_) removes the guess. The rendered links are
identical before and after.

Verified

Built CPython 3.14 Doc/ against this branch with
sphinx-doc/sphinx#14357 applied:

i18n.inconsistent_references all warnings + errors
3.14 as-is 12 12
this branch 0 0

Note on wrapping

My local gettext is 1.0, and its wrapping differs from whatever produced the current
files — the new version does not break inside a reST role, the older one does. Running
powrap here rewraps every file and turns this into a ~5000 line diff, so I did not run
it
. Instead the lines before each change are left byte-identical and only the text from
the change onwards is re-wrapped. Please run make wrap before merging so the project's
own tooling normalises it.

🤖 Generated with Claude Code

13 translated messages use a different role from their msgid, for
example `:data:`typing.Union`` where the source says
`:class:`typing.Union``.

Five of them render with no link at all, because the role points at the
wrong domain:

* library/asyncio-eventloop.po (x3): `socket-unix-constants` is a label,
  but the translation used `:py:const:`, which looks for a Python object
  of that name and finds none. The `~` prefix is dropped too, since
  `:ref:` does not strip a module path.
* whatsnew/3.12.po (x2): `Py_TPFLAGS_ITEMS_AT_END` and
  `Py_TPFLAGS_IMMUTABLETYPE` are C macros, but the translation used
  `:const:`, which only searches the Python domain.

The other eight still resolve, because the Python domain's `find_obj()`
ignores the object type when the target has no leading dot, so only the
rendered CSS class differs. They are corrected for consistency.

Only the role token changed in each message; the translated text is
otherwise untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://python.github.io/python-docs-zh-tw/pr-preview/pr-1244/

Built to branch gh-pages at 2026-09-29 17:58 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@mattwang44
mattwang44 marked this pull request as ready for review September 30, 2026 03:13
Both link names in this message are translated. When a message contains
more than one translated reference name, Sphinx's fix-up has to guess
which original target each one means, so it cannot verify the result.
Naming the targets explicitly removes the guess; the rendered links are
unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@mattwang44
mattwang44 marked this pull request as draft September 30, 2026 03:19

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant