Skip to content

Conversation

Aniketsy
Copy link
Contributor

@Aniketsy Aniketsy commented Sep 21, 2025

#139181
This PR wraps the html_short_title string in conf.py with the Sphinx translation function _().

Please let me know if my approach or fix needs any improvements . I’m open to feedback and happy to make changes based on suggestions.
Thankyou !


📚 Documentation preview 📚: https://cpython-previews--139195.org.readthedocs.build/

Copy link
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, however there are several issue:

  • The version number, which does not need to be translated, changes quite frequently. Just translating "Documentation" would be much easier, rather than translating every few months. e.g.:
    html_short_title = _('%(release)s Documentation') % {'release': release}
    
  • Testing locally I see that the string is not extracted by the gettext builder, it's also not particularly clear what catalogue it's using? I tried putting it into the sphinx domain but that didn't work.
  • This also breaks epub builds.
  • There are also other strings that can be translated, e.g. "Python Documentation Authors".

@Aniketsy
Copy link
Contributor Author

Thank you for the feedback! I’ll look into these issues and see if I can fix them. Any guidance you can provide would be greatly appreciated.

@AA-Turner AA-Turner added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Sep 21, 2025
@zware
Copy link
Member

zware commented Sep 22, 2025

  • The version number, which does not need to be translated, changes quite frequently. Just translating "Documentation" would be much easier, rather than translating every few months.

The trouble with translating just part of the string is that for some languages 3.13.7 Documentation might be better translated as Documentation for 3.13.7 or For 3.13.7, Documentation, etc. Ideally the template would be translated before formatting.

@StanFromIreland
Copy link
Member

I was thinking:

html_short_title = _('%(release)s Documentation') % {'release': release}

translators are used to named placeholders.

Comment on lines +450 to +451
epub_author = _('Python Documentation Authors')
epub_publisher = _('Python Software Foundation')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI is failing with:

WARNING: The config value `epub_author' has type `_TranslationProxy'; expected `str'.
WARNING: The config value `epub_publisher' has type `_TranslationProxy'; expected `str'.

Does Sphinx need an update for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not entirely sure about this. I added the changes based on a suggestion, but if they’re not required, I can remove them.
@StanFromIreland Could you please confirm whether these changes are actually needed ?

@StanFromIreland
Copy link
Member

You may find people's workarounds (Sphinx provides no native support) here helpful: sphinx-doc/sphinx#1260

@AA-Turner
Copy link
Member

This appears to be something that needs fixing in Sphinx first, so I'll close this PR for now.

A

@AA-Turner AA-Turner closed this Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants