fix: align cross-reference roles with the English source - #1244
Draft
mattwang44 wants to merge 2 commits into
Draft
mattwang44 wants to merge 2 commits into
mattwang44 wants to merge 2 commits into
Conversation
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>
Contributor
|
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
marked this pull request as draft
September 30, 2026 03:19
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
13 translated messages use a different role from the one in their
msgid. For example thesource 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:
library/asyncio-eventloop.po×3whatsnew/3.12.po×2socket-unix-constantsis a label.:py:const:looks for a Python object with thatname and finds none. The
~prefix is dropped as well, because:ref:does not strip amodule path.
Py_TPFLAGS_ITEMS_AT_ENDandPy_TPFLAGS_IMMUTABLETYPEare C macros.:const:onlysearches the Python domain.
The other eight still resolve, because the Python domain's
find_obj()ignores theobject type when the target has no leading dot, so a wrong role still finds the object and
only the rendered CSS class differs (
py-datavspy-class). They are corrected forconsistency with the source.
What changed
library/functools.po:data::class:typing.Unionlibrary/stdtypes.po×2:data::class:typing.Unionlibrary/asyncio-future.po:func::meth:concurrent.futures.Future.canceltutorial/errors.po:class::exc:Exceptionlibrary/sys.po:attr::data:sys.builtin_module_nameslibrary/typing.po:func::ref:overloaded functions <overload>whatsnew/3.12.po:data::const:os.PIDFD_NONBLOCKOnly 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 --checkpasses on every file.Background
I found these while testing a fix for
sphinx-doc/sphinx#14162. Sphinx today
compares only the
reftarget, which issocket-unix-constantson both sides, so it doesnot 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.pobugs.rst:105translates both link names in the same message. When a message containsmore 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 areidentical before and after.
Verified
Built CPython 3.14
Doc/against this branch withsphinx-doc/sphinx#14357 applied:
i18n.inconsistent_references3.14as-isNote on wrapping
My local
gettextis 1.0, and its wrapping differs from whatever produced the currentfiles — the new version does not break inside a reST role, the older one does. Running
powraphere rewraps every file and turns this into a ~5000 line diff, so I did not runit. Instead the lines before each change are left byte-identical and only the text from
the change onwards is re-wrapped. Please run
make wrapbefore merging so the project'sown tooling normalises it.
🤖 Generated with Claude Code