Re: [PATCH] docs: translations: add translations links when they exist
From: Jonathan Corbet
Date: Fri Nov 17 2023 - 15:54:43 EST
Vegard Nossum <vegard.nossum@xxxxxxxxxx> writes:
> Add a new Sphinx extension that knows about the translations of kernel
> documentation and can insert links to the translations at the top of
> the document.
>
> It basically works like this:
>
> 1. Register a new node type, LanguagesNode.
>
> 2. Register a new transform, TranslationsTransform, that inserts a new
> LanguageNode at the top of every document. The LanguageNode contains
> "pending references" to translations of the document. The key here
> is that these are pending (i.e. unresolved) references that may or
> may not actually exist.
>
> 3. Register a 'doctree-resolved' event that iterates over all the
> LanguageNode nodes. Any unresolved references are filtered out; the
> list of resolved references is passed to the 'translations.html'
> template and rendered as an HTML node (if HTML output is selected).
>
> Testing: make htmldocs with v7.3.0.
>
> Signed-off-by: Vegard Nossum <vegard.nossum@xxxxxxxxxx>
> ---
> Documentation/conf.py | 2 +-
> Documentation/sphinx-static/custom.css | 8 ++
> .../sphinx/templates/translations.html | 12 +++
> Documentation/sphinx/translations.py | 96 +++++++++++++++++++
> 4 files changed, 117 insertions(+), 1 deletion(-)
> create mode 100644 Documentation/sphinx/templates/translations.html
> create mode 100644 Documentation/sphinx/translations.py
OK, this does seem to work.
The naming of the translations definitely needs to change; if we put out
something with "Taiwanese" in it, experience tells me, there will be
objections - and that's not what the translation was called when it was
added.
I'm unsure about putting the languages in the top bar like that; it will
already become pretty wide with the relabeled translations, and may not
look great on a small-screen device. Perhaps a pulldown would be
better?
The build problem reported by Akira definitely needs to be fixed as
well.
Thanks,
jon