Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-126609: localize list, allow translation of a phrase, use ge operator character in the availability directive#129597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
a2399c08de15eac9ee08d88a9a9ee6fe49e2cb41d9f273e6eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -2,8 +2,10 @@ | ||||||
| from __future__ import annotations | ||||||
| from itertools import starmap | ||||||
| from typing import TYPE_CHECKING | ||||||
| from babel.lists import format_list | ||||||
| from docutils import nodes | ||||||
| from sphinx import addnodes | ||||||
| from sphinx.locale import _ as sphinx_gettext | ||||||
| @@ -68,14 +70,15 @@ def run(self) -> list[nodes.container]: | ||||||
| refwarn=True, | ||||||
| ) | ||||||
| sep = nodes.Text(": ") | ||||||
| parsed, msgs = self.state.inline_text(self.arguments[0], self.lineno) | ||||||
| platforms = self.parse_platforms() | ||||||
| platforms_text = f"{format_list(list(starmap(_format_platform, platforms.items())), locale=self.config.language)}." | ||||||
| parsed, msgs = self.state.inline_text(platforms_text, self.lineno) | ||||||
| pnode = nodes.paragraph(title, "", refnode, sep, *parsed, *msgs) | ||||||
| self.set_source_info(pnode) | ||||||
| cnode = nodes.container("", pnode, classes=["availability"]) | ||||||
| self.set_source_info(cnode) | ||||||
| if self.content: | ||||||
| self.state.nested_parse(self.content, self.content_offset, cnode) | ||||||
| self.parse_platforms() | ||||||
| return [cnode] | ||||||
| @@ -116,6 +119,14 @@ def parse_platforms(self) -> dict[str, str | bool]: | ||||||
| return platforms | ||||||
| def _format_platform(platform: str, version: str | bool) -> str: | ||||||
| if version is True: | ||||||
| return platform | ||||||
| if not version: | ||||||
| return sphinx_gettext("not{platform}").format(platform=platform) | ||||||
| return f"{platform} ≥{version}" | ||||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggested change
How well supported is "≥"? Does it render well in pdf outputs? Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ContributorAuthor
| ||||||
| def setup(app: Sphinx) -> ExtensionMetadata: | ||||||
| app.add_directive("availability", Availability) | ||||||
Uh oh!
There was an error while loading. Please reload this page.


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.Uh oh!
There was an error while loading. Please reload this page.
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.