fix: write region names in pack READMEs as labels

packreadme title-cased each slug, printing asia-ntsc as Asia Ntsc.
region.label() holds the words the site already used, and both read it.
This commit is contained in:
Abdessamad Derraz committed 2026-11-06 03:50:49 +01:00
1 parent 00aac8dc72
commit 2f81aa9c0f
4 files changed
+38 -11

No files matched your search

+5 -8
View File
@@ -7750,20 +7750,17 @@ def _distinct_spellings(names: list) -> list[str]:
return list(seen.values())
# Region slugs whose words are not the slug title-cased.
_REGION_WORDS = {
"uk": "UK",
"asia-ntsc": "Asia (NTSC)",
"asia-pal": "Asia (PAL)",
"world": "every region",
}
# Region slugs whose words are not the slug title-cased, beyond region.LABELS.
_REGION_WORDS = {"world": "every region"}
def _region_words(value: object, most: int = 0) -> str:
"""A region: value in words. ``most`` caps the regions named, the rest
counted: one Saturn BIOS serves seven."""
raw = value if isinstance(value, list) else [value] if value else []
words = [_REGION_WORDS.get(str(r), str(r).replace("-", " ").title()) for r in raw]
from region import label # noqa: PLC0415
words = [_REGION_WORDS.get(str(r)) or label(str(r)) for r in raw]
if most and len(words) > most:
words = words[:most] + [f"{len(words) - most} more"]
return _said_as_list(words)
+2 -3
View File
@@ -5,6 +5,7 @@ goes, and which ones the user has to rename."""
from __future__ import annotations
from region import label as region_label
from siteguides import INSTALL_PS1, INSTALL_SH, pack_manual
def _detect_systems(detect: list[dict]) -> list[str]:
@@ -290,9 +291,7 @@ def _build_readme(
region_info = ""
if regions:
pretty = ", ".join(
" ".join(w.title() for w in slug.split("-")) for slug in regions
)
pretty = ", ".join(region_label(slug) for slug in regions)
region_info = (
"PACK TYPE: Region Filtered\n\n"
f" Region priority: {pretty}\n\n"
+13
View File
@@ -107,6 +107,19 @@ ALIASES: dict[str, str] = {
}
# Slugs a person does not write title-cased: "Asia Ntsc" read as machine text.
LABELS: dict[str, str] = {
"uk": "UK",
"asia-ntsc": "Asia (NTSC)",
"asia-pal": "Asia (PAL)",
}
def label(slug: str) -> str:
"""A region slug in words: north-america as North America."""
return LABELS.get(slug) or " ".join(word.title() for word in slug.split("-"))
def unknown_region_message(raw: str, aliases: dict[str, str], regions: frozenset[str]) -> str:
"""What to type instead: the closest spellings, then every short form.