Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion archinstall/lib/utils/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
from _typeshed import DataclassInstance


def _sentence_case(text: str) -> str:
# Only capitalize the first letter of the label. The source strings and
# their translations are already written with the correct casing for each
# language, so title-casing every word is wrong outside English (it turned
# "Ім'я хоста" into "Ім'Я Хоста" and "(NTP)" into "(Ntp)").
return text[:1].upper() + text[1:]


def as_key_value_pair(
entries: dict[str, str | list[str] | bool],
ignore_empty: bool = True,
Expand All @@ -33,7 +41,7 @@ def as_key_value_pair(
if isinstance(value, list):
value = '\n '.join(str(val) for val in value)

table.add_row(label.title(), f': {value}')
table.add_row(_sentence_case(label), f': {value}')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please use .title()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The problem is that .title() is exactly what breaks the summary. It upper-cases the letter after every non-alpha character, not just spaces, so it mangles anything that is not plain English words:

  • Ukrainian: "Ім'я хоста" becomes "Ім'Я Хоста" (capital after the apostrophe)
  • acronyms: "Automatic time sync (NTP)" becomes "Automatic Time Sync (Ntp)"

The label strings and their translations are already written with the correct casing, so re-casing them per word is wrong for every locale, English included. Capitalizing just the first letter keeps Mirrors and repositories reading as sentence case while leaving NTP and translated strings intact. That is the whole point of this PR, so switching back to .title() would reintroduce the bug.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Apologies I clearly didn't read the description carefully enough


return table.stringify()

Expand Down