GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-126609: localize list, allow translation of a phrase, use ge operator character in the availability directive by m-aciek · Pull Request #129597 · python/cpython

Conversation

@m-aciek

@m-aciek m-aciek commented Feb 2, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  1. Localizes platform support lists using Babel's format_list().
  2. Exposes translation phrase not {platform} and fetches its translation in the availability directive content. This will allow full translations of availability directive content.
  3. Renders text-based greater-than or equal-to sing >= as UTF-8 ≥.

Tested locally, both make gettext (exposes new phrase in sphinx.pot) and rendering with make html. Examples of renderings:

library/os.rst:2311

  • original:
Zrzut ekranu 2025-02-3 o 11 47 58
  • Traditional Chinese:
Zrzut ekranu 2025-02-3 o 12 06 24
  • Polish:
Zrzut ekranu 2025-02-3 o 12 06 35

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

  • Issue: Availability extension's text translation breaks directive rendering #126609

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tomasr8 and StanFromIreland reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
m-aciek added 2 commits February 2, 2025 21:45
@m-aciek
Docs: allow translation of a phrase in availability directive
a2399c0
@m-aciek
Use greater-than or equal-to character
8de15ea
@m-aciek
m-aciek requested review from AA-Turner and hugovk as code owners February 2, 2025 20:54
@bedevere-app bedevere-app Bot added the awaiting review label Feb 2, 2025
@m-aciek m-aciek changed the title Docs: allow translation of a phrase in the availability directive Docs: allow translation of a phrase in the availability directive, use ge operator character Feb 2, 2025
@m-aciek m-aciek changed the title Docs: allow translation of a phrase in the availability directive, use ge operator character Docs: allow translation of a phrase, use ge operator character in the availability directive Feb 2, 2025
m-aciek added 2 commits February 3, 2025 00:03
@m-aciek
Refactor: move helper function down
c9ee08d
@m-aciek
Fix type annotations
88a9a9e
AA-Turner
AA-Turner reviewed Feb 2, 2025
View reviewed changes
Comment thread Doc/tools/extensions/availability.py
refwarn=True,
)
sep = nodes.Text(": ")
parsed, msgs = self.state.inline_text(self.arguments[0], self.lineno)

@AA-Turner AA-Turner Feb 2, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It is somewhat surprising that this doesn't work, as sphinx.util.nodes.extract_messages() should pick up the rawsource attributes -- we shouldn't need to parse & reparse.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@m-aciek m-aciek Feb 3, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Even when I've added not WASI, not Android. translation string by hand, it wasn't picked up in the build process.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@AA-Turner AA-Turner added the skip news label Feb 2, 2025
@AA-Turner AA-Turner changed the title Docs: allow translation of a phrase, use ge operator character in the availability directive gh-126609: allow translation of a phrase, use ge operator character in the availability directive Feb 2, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Feb 2, 2025
Availability extension's text translation breaks directive rendering #126609
Closed
tomasr8
tomasr8 reviewed Feb 2, 2025
View reviewed changes
Comment thread Doc/tools/extensions/availability.py Outdated
parsed, msgs = self.state.inline_text(self.arguments[0], self.lineno)
platforms = self.parse_platforms()
platforms_text = (
f"{', '.join(starmap(_print_platform, platforms.items()))}."

@tomasr8 tomasr8 Feb 2, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Not sure if babel is available here, but format_list might be a better option?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@m-aciek m-aciek Feb 3, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Babel is Sphinx's dependency, it is available. Thank you for the suggestion, I've added it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tomasr8 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@m-aciek
Use Babel's format_list()
e6fe49e
@m-aciek m-aciek changed the title gh-126609: allow translation of a phrase, use ge operator character in the availability directive gh-126609: localize list, allow translation of a phrase, use ge operator character in the availability directive Feb 3, 2025
StanFromIreland
StanFromIreland approved these changes Feb 3, 2025
View reviewed changes

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Other than my little nitpick it looks very good!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/tools/extensions/availability.py
return platform
if not version:
return sphinx_gettext("not {platform}").format(platform=platform)
return f"{platform} ≥ {version}"

@StanFromIreland StanFromIreland Feb 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
return f"{platform} ≥ {version}"
return f"{platform} >= {version}"

How well supported is "≥"? Does it render well in pdf outputs?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@StanFromIreland StanFromIreland Feb 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

epub
image

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@m-aciek m-aciek Feb 3, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@AA-Turner could you please advise, is there some direct way to recognize epub build in the directive code and fallback to >=? Or should I rather drop the UTF-8 character from here?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@hugovk hugovk Feb 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I find no mention of using "≥" or ">=" for versions in the Google, Microsoft and Apple style guides, and they say to use words such as "Use version 2.2 or later" and not "Use version 2.2 or higher":

  • https://developers.google.com/style/word-list#later
  • https://learn.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/l/later
  • https://support.apple.com/en-gb/guide/applestyleguide/apsg51b3c806/web

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@StanFromIreland StanFromIreland Feb 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I agree with @hugovk . This again will require translation.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@StanFromIreland StanFromIreland Feb 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I will add that >= is currently used.

image

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@m-aciek m-aciek Feb 3, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

  • https://developers.google.com/style/word-list#later

I find Google's style guide contradictory 🤔

A release with the highest version number might not be the latest version. For example, if version 2.0 of an operating system receives a bug-fix update after version 3.0 has been released, then version 2.0.1 might be the latest version, even though its version number is lower than 3.0.

In this meaning we rather want to express "higher" than "later". And later they recommend higher in Android docs. I've filed a feedback to this section.

I agree that the written form may be easier to read than the symbolic one. Though ≥ seems to be inambiguous, contrary to “later”.

I will add that >= is currently used.

I wonder what should be the approach, if we decide to use "Linux 2.6.27 or later", should we rewrite also the availability directives content in .rsts? Or introduce a simplified "syntax", that will be rendered to "or later" from a ">=" specificator? That may be confusing to docs editors. (?)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@hugovk hugovk Feb 4, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

If we choose to use words, I'd rewrite the existing ">=" to avoid problems/confusion by automation changing things in unexpected ways.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@hugovk hugovk Feb 4, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We discussed this in this month's docs workgroup meeting: let's keep the directives compact; they're not prose, and use the single symbol. The Unicode symbol was introduced in 1993, hopefully it renders well on near anything. If there's an issue with Unicode in some of the backends (such as man pages), we should fix that.

(Minutes will appear at https://docs-community.readthedocs.io/en/latest/monthly-meeting/index.html in the near future.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Feb 3, 2025
hugovk
hugovk reviewed Feb 3, 2025
View reviewed changes
Comment thread Doc/tools/extensions/availability.py
return platform
if not version:
return sphinx_gettext("not {platform}").format(platform=platform)
return f"{platform} ≥ {version}"

@hugovk hugovk Feb 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I find no mention of using "≥" or ">=" for versions in the Google, Microsoft and Apple style guides, and they say to use words such as "Use version 2.2 or later" and not "Use version 2.2 or higher":

  • https://developers.google.com/style/word-list#later
  • https://learn.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/l/later
  • https://support.apple.com/en-gb/guide/applestyleguide/apsg51b3c806/web

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/tools/extensions/availability.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/tools/extensions/availability.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

m-aciek and others added 2 commits February 3, 2025 22:40
@m-aciek @hugovk
Rename _print_platform() to _format_platform()
2cb41d9
Co-authored-by: Hugo van Kemenade <[email protected]>
@m-aciek @hugovk
Rename formatting function in a call
f273e6e
Co-authored-by: Hugo van Kemenade <[email protected]>
@AA-Turner

AA-Turner commented Feb 4, 2025

Copy link
Copy Markdown
Member

It would be good to properly investigate why the gettext builder is not picking up the raw text here. In the other part of #126609, there was a fairly simple resolution instead of a partial revert -- the PR as it stands now is duplicative, parsing and re-creating the text provided to the directive, whereas currently we just validate that it is correct. If we fix the source text being picked up by gettext, it would also mean that we don't need babel.lists, as translators can simply translate the source text naturally. As such, I've added the DO-NOT-MERGE label for the time being.

A

m-aciek reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner AA-Turner added the DO-NOT-MERGE label Feb 4, 2025
@m-aciek
m-aciek marked this pull request as draft February 4, 2025 14:26
@bedevere-app bedevere-app Bot removed the awaiting core review label Feb 4, 2025
@m-aciek

m-aciek commented Feb 19, 2025

Copy link
Copy Markdown
Contributor Author

I'm convinced that we should translate the full text, instead of building it from fragments (vide Prefer WET over DRY for i18n). Therefore I will close this PR. I didn't yet succeed with the correct solution. I will try to write my findings in related discussion thread soon https://github.com/orgs/sphinx-doc/discussions/13280.

tomasr8 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@m-aciek m-aciek closed this Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hugovk hugovk hugovk left review comments
@tomasr8 tomasr8 tomasr8 left review comments
@AA-Turner AA-Turner AA-Turner left review comments
@StanFromIreland StanFromIreland StanFromIreland approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

DO-NOT-MERGE skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@m-aciek @AA-Turner @hugovk @tomasr8 @StanFromIreland
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.