feat(installer): translate the summary screen
This commit is contained in:
1 file changed
+100
-67
+100
-67
@@ -50,29 +50,38 @@ from pyanaconda.modules.common.structures.user import UserData
|
|||||||
from pyanaconda.ui.gui import GraphicalUserInterface
|
from pyanaconda.ui.gui import GraphicalUserInterface
|
||||||
from pyanaconda.ui.gui.hubs.summary import SummaryHub
|
from pyanaconda.ui.gui.hubs.summary import SummaryHub
|
||||||
from pyanaconda.ui.gui.spokes import StandaloneSpoke
|
from pyanaconda.ui.gui.spokes import StandaloneSpoke
|
||||||
|
from pyanaconda.ui.gui.spokes.fws_i18n import t
|
||||||
|
|
||||||
log = get_module_logger(__name__)
|
log = get_module_logger(__name__)
|
||||||
|
|
||||||
__all__ = ["FWSRecapSpoke"]
|
__all__ = ["FWSRecapSpoke"]
|
||||||
|
|
||||||
|
|
||||||
# Doit rester aligné sur le %post du kickstart (étape « Bureau choisi ») et
|
# Doit rester aligné sur le %post du kickstart (étape « Bureau choisi ») et
|
||||||
# sur les libellés de la spoke fws_desktop.
|
# sur les libellés de la spoke fws_desktop.
|
||||||
_DESKTOP_LABELS = {
|
def _desktop_label(desk):
|
||||||
"cli": "ligne de commande uniquement (aucun bureau)",
|
# Built on each call rather than kept as a module constant, so the labels
|
||||||
"gnome": "GNOME (+ Firefox, GDM)",
|
# follow a language changed on the first screen.
|
||||||
"kde": "KDE Plasma (+ Firefox, SDDM)",
|
labels = {
|
||||||
"hyprland": "Hyprland — Wayland, non compatible VR (+ Firefox, SDDM)",
|
"cli": t("recap.desktop_cli"),
|
||||||
"i3": "i3 — X11, compatible VR/SteamVR (+ Firefox, SDDM)",
|
"gnome": t("recap.desktop_gnome"),
|
||||||
"xfce": "XFCE (+ Firefox, SDDM)",
|
"kde": t("recap.desktop_kde"),
|
||||||
}
|
"hyprland": t("recap.desktop_hyprland"),
|
||||||
|
"i3": t("recap.desktop_i3"),
|
||||||
|
"xfce": t("recap.desktop_xfce"),
|
||||||
|
}
|
||||||
|
return labels.get(desk, desk)
|
||||||
|
|
||||||
_PARTITIONING_LABELS = {
|
|
||||||
"AUTOMATIC": "automatique (recommandé)",
|
def _partitioning_label(method):
|
||||||
"INTERACTIVE": "personnalisé (assistant)",
|
labels = {
|
||||||
"CUSTOM": "personnalisé",
|
"AUTOMATIC": t("recap.partitioning_automatic"),
|
||||||
"BLIVET": "avancé (blivet-gui)",
|
"INTERACTIVE": t("recap.partitioning_interactive"),
|
||||||
"MANUAL": "points de montage manuels",
|
"CUSTOM": t("recap.partitioning_custom"),
|
||||||
}
|
"BLIVET": t("recap.partitioning_blivet"),
|
||||||
|
"MANUAL": t("recap.partitioning_manual"),
|
||||||
|
}
|
||||||
|
return labels.get(method, method)
|
||||||
|
|
||||||
|
|
||||||
def _safe(getter, default):
|
def _safe(getter, default):
|
||||||
@@ -108,67 +117,82 @@ def _config_lines():
|
|||||||
|
|
||||||
lang = _safe(lambda: LOCALIZATION.get_proxy().Language, "")
|
lang = _safe(lambda: LOCALIZATION.get_proxy().Language, "")
|
||||||
if lang:
|
if lang:
|
||||||
lines.append(f" • Langue : {lang}")
|
lines.append((t("recap.row_language"), lang))
|
||||||
|
|
||||||
layouts = _safe(lambda: list(LOCALIZATION.get_proxy().XLayouts), [])
|
layouts = _safe(lambda: list(LOCALIZATION.get_proxy().XLayouts), [])
|
||||||
if layouts:
|
if layouts:
|
||||||
lines.append(f" • Clavier (X11) : {', '.join(layouts)}")
|
lines.append((t("recap.row_keyboard"), ", ".join(layouts)))
|
||||||
|
|
||||||
tz = _safe(lambda: TIMEZONE.get_proxy().Timezone, "")
|
tz = _safe(lambda: TIMEZONE.get_proxy().Timezone, "")
|
||||||
if tz:
|
if tz:
|
||||||
ntp = _safe(lambda: TIMEZONE.get_proxy().NTPEnabled, None)
|
ntp = _safe(lambda: TIMEZONE.get_proxy().NTPEnabled, None)
|
||||||
suffix = {True: " — synchronisation NTP activée",
|
tz_txt = {True: t("recap.timezone_ntp_on", timezone=tz),
|
||||||
False: " — synchronisation NTP désactivée"}.get(ntp, "")
|
False: t("recap.timezone_ntp_off", timezone=tz)}.get(ntp, tz)
|
||||||
lines.append(f" • Fuseau horaire : {tz}{suffix}")
|
lines.append((t("recap.row_timezone"), tz_txt))
|
||||||
|
|
||||||
users = _safe(
|
users = _safe(
|
||||||
lambda: UserData.from_structure_list(USERS.get_proxy().Users), [])
|
lambda: UserData.from_structure_list(USERS.get_proxy().Users), [])
|
||||||
if users:
|
if users:
|
||||||
names = ", ".join(u.name for u in users if u.name)
|
names = ", ".join(u.name for u in users if u.name)
|
||||||
lines.append(f" • Utilisateur(s) : {names} (sudo via wheel)")
|
lines.append((t("recap.row_users"), t("recap.users_value", users=names)))
|
||||||
else:
|
else:
|
||||||
lines.append(" • Utilisateur(s) : AUCUN — pensez-y avant de lancer !")
|
lines.append((t("recap.row_users"), t("recap.users_none")))
|
||||||
|
|
||||||
root_locked = _safe(lambda: USERS.get_proxy().IsRootAccountLocked, None)
|
root_locked = _safe(lambda: USERS.get_proxy().IsRootAccountLocked, None)
|
||||||
root_pw = _safe(lambda: USERS.get_proxy().IsRootPasswordSet, None)
|
root_pw = _safe(lambda: USERS.get_proxy().IsRootPasswordSet, None)
|
||||||
if root_locked:
|
if root_locked:
|
||||||
root_txt = "verrouillé (recommandé)"
|
root_txt = t("recap.root_locked")
|
||||||
elif root_pw:
|
elif root_pw:
|
||||||
root_txt = "actif, mot de passe défini"
|
root_txt = t("recap.root_password_set")
|
||||||
elif root_pw is not None:
|
elif root_pw is not None:
|
||||||
# Même règle que l'étape « Sécurité » du %post : un root resté sans
|
# Même règle que l'étape « Sécurité » du %post : un root resté sans
|
||||||
# mot de passe sera verrouillé en fin d'installation.
|
# mot de passe sera verrouillé en fin d'installation.
|
||||||
root_txt = "sans mot de passe → sera VERROUILLÉ en fin d'install"
|
root_txt = t("recap.root_no_password")
|
||||||
else:
|
else:
|
||||||
root_txt = ""
|
root_txt = ""
|
||||||
if root_txt:
|
if root_txt:
|
||||||
lines.append(f" • Compte root : {root_txt}")
|
lines.append((t("recap.row_root"), root_txt))
|
||||||
|
|
||||||
# Hostname : écrit par le spoke Utilisateur (patch user.py du paquet
|
# Hostname : écrit par le spoke Utilisateur (patch user.py du paquet
|
||||||
# anaconda). Même nettoyage / même défaut que le %post --nochroot.
|
# anaconda). Même nettoyage / même défaut que le %post --nochroot.
|
||||||
hn = "".join(c for c in _read_flag("/tmp/fws-hostname")
|
hn = "".join(c for c in _read_flag("/tmp/fws-hostname")
|
||||||
if c.isalnum() or c in "._-") or "fws"
|
if c.isalnum() or c in "._-") or "fws"
|
||||||
lines.append(f" • Nom de machine : {hn}")
|
lines.append((t("recap.row_hostname"), hn))
|
||||||
|
|
||||||
# Bureau : écrit par fws_desktop.apply() (sortie de la spoke). Absent =
|
# Bureau : écrit par fws_desktop.apply() (sortie de la spoke). Absent =
|
||||||
# spoke jamais visitée = « cli », exactement le défaut du %post.
|
# spoke jamais visitée = « cli », exactement le défaut du %post.
|
||||||
desk = _read_flag("/tmp/fws-desktop") or "cli"
|
desk = _read_flag("/tmp/fws-desktop") or "cli"
|
||||||
lines.append(f" • Bureau : {_DESKTOP_LABELS.get(desk, desk)}")
|
lines.append((t("recap.row_desktop"), _desktop_label(desk)))
|
||||||
|
|
||||||
method = _safe(
|
method = _safe(
|
||||||
lambda: STORAGE.get_proxy(
|
lambda: STORAGE.get_proxy(
|
||||||
STORAGE.get_proxy().AppliedPartitioning).PartitioningMethod, "")
|
STORAGE.get_proxy().AppliedPartitioning).PartitioningMethod, "")
|
||||||
if method:
|
if method:
|
||||||
lines.append(" • Partitionnement : "
|
lines.append((t("recap.row_partitioning"), _partitioning_label(method)))
|
||||||
f"{_PARTITIONING_LABELS.get(method, method)}")
|
|
||||||
|
|
||||||
return lines, desk, method
|
return lines, desk, method
|
||||||
|
|
||||||
|
|
||||||
|
def _format_rows(rows, width):
|
||||||
|
"""Lay out (label, value) pairs as " • label : value" lines."""
|
||||||
|
# Labels are padded to the longest one of the current language so the
|
||||||
|
# values line up in the monospace view; the line breaks a translation
|
||||||
|
# puts in a value continue under the value column.
|
||||||
|
lines = []
|
||||||
|
for label, value in rows:
|
||||||
|
prefix = f" • {label:<{width}} : "
|
||||||
|
lines.append(prefix + value.replace("\n", "\n" + " " * len(prefix)))
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
def _indent(text):
|
||||||
|
# Translations keep their own line breaks; the indentation is layout and
|
||||||
|
# stays here.
|
||||||
|
return "\n".join(" " + line for line in text.splitlines())
|
||||||
|
|
||||||
|
|
||||||
def _build_summary():
|
def _build_summary():
|
||||||
config_lines, desk, method = _config_lines()
|
config_lines, desk, method = _config_lines()
|
||||||
config_text = "\n".join(config_lines) \
|
|
||||||
or " (configuration non disponible)"
|
|
||||||
|
|
||||||
# Disques ciblés par l'installation (spoke « Destination »).
|
# Disques ciblés par l'installation (spoke « Destination »).
|
||||||
selected = set(_safe(
|
selected = set(_safe(
|
||||||
@@ -177,70 +201,71 @@ def _build_summary():
|
|||||||
for line in _capture("lsblk", "-dno", "NAME,SIZE,MODEL,TYPE").splitlines():
|
for line in _capture("lsblk", "-dno", "NAME,SIZE,MODEL,TYPE").splitlines():
|
||||||
fields = line.split()
|
fields = line.split()
|
||||||
if fields and fields[-1] == "disk":
|
if fields and fields[-1] == "disk":
|
||||||
mark = " ← CIBLE de l'installation" if fields[0] in selected else ""
|
disk = " ".join(fields[:-1])
|
||||||
disks.append(" • " + " ".join(fields[:-1]) + mark)
|
if fields[0] in selected:
|
||||||
disk_text = "\n".join(disks) or " (aucun disque détecté)"
|
disk = t("recap.disk_target", disk=disk)
|
||||||
|
disks.append(" • " + disk)
|
||||||
|
disk_text = "\n".join(disks) or _indent(t("recap.no_disk"))
|
||||||
|
|
||||||
if method == "AUTOMATIC":
|
if method == "AUTOMATIC":
|
||||||
disk_warn = (
|
disk_warn = _indent(t("recap.disk_warning_automatic"))
|
||||||
" ⚠ Rien n'a encore été écrit. Le partitionnement automatique\n"
|
|
||||||
" EFFACERA ENTIÈREMENT le(s) disque(s) cible(s) au lancement.")
|
|
||||||
else:
|
else:
|
||||||
disk_warn = (
|
disk_warn = _indent(t("recap.disk_warning_manual"))
|
||||||
" ⚠ Rien n'a encore été écrit. Au lancement, ce sont vos choix\n"
|
|
||||||
" de partitionnement faits dans l'installateur qui s'appliqueront.")
|
|
||||||
|
|
||||||
virt = (_capture("systemd-detect-virt").strip().splitlines() or ["none"])[0]
|
virt = (_capture("systemd-detect-virt").strip().splitlines() or ["none"])[0]
|
||||||
if virt in ("", "none"):
|
if virt in ("", "none"):
|
||||||
virt = "aucune (machine physique)"
|
virt = t("recap.virtualization_none")
|
||||||
|
|
||||||
gpus = []
|
gpus = []
|
||||||
for line in _capture("lspci").splitlines():
|
for line in _capture("lspci").splitlines():
|
||||||
low = line.lower()
|
low = line.lower()
|
||||||
if ("vga" in low or "3d" in low or "display" in low) and ":" in line:
|
if ("vga" in low or "3d" in low or "display" in low) and ":" in line:
|
||||||
gpus.append(" • " + line.split(":", 2)[-1].strip())
|
gpus.append(" • " + line.split(":", 2)[-1].strip())
|
||||||
gpu_text = "\n".join(gpus) or " (aucune carte graphique détectée)"
|
gpu_text = "\n".join(gpus) or _indent(t("recap.no_gpu"))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
net_ok = util.execWithRedirect("ip", ["route", "get", "1.1.1.1"]) == 0
|
net_ok = util.execWithRedirect("ip", ["route", "get", "1.1.1.1"]) == 0
|
||||||
except (OSError, RuntimeError):
|
except (OSError, RuntimeError):
|
||||||
net_ok = False
|
net_ok = False
|
||||||
if net_ok:
|
if net_ok:
|
||||||
net = "disponible ✔"
|
net = t("recap.network_ok")
|
||||||
else:
|
else:
|
||||||
net = ("INDISPONIBLE ✖ — bureau, drivers et stack FWS ne\n"
|
net = t("recap.network_down")
|
||||||
" s'installeront PAS (rattrapable au 1er boot)")
|
|
||||||
|
|
||||||
extras = ("Steam, Wine, VR (Monado/OpenXR), PacManager"
|
extras = (t("recap.extras_desktop")
|
||||||
if desk != "cli" else "rien de plus (choix CLI)")
|
if desk != "cli" else t("recap.extras_cli"))
|
||||||
|
|
||||||
|
hardware_lines = [(t("recap.row_virtualization"), virt),
|
||||||
|
(t("recap.row_network"), net)]
|
||||||
|
width = max(len(label) for label, _ in config_lines + hardware_lines)
|
||||||
|
config_text = _format_rows(config_lines, width) \
|
||||||
|
or _indent(t("recap.config_unavailable"))
|
||||||
|
|
||||||
return f"""\
|
return f"""\
|
||||||
══════════════════════════════════════════════════════════
|
══════════════════════════════════════════════════════════
|
||||||
FWS — RÉCAPITULATIF AVANT INSTALLATION
|
{t("recap.summary_title")}
|
||||||
══════════════════════════════════════════════════════════
|
══════════════════════════════════════════════════════════
|
||||||
|
|
||||||
CONFIGURATION CHOISIE
|
{t("recap.section_config")}
|
||||||
{config_text}
|
{config_text}
|
||||||
|
|
||||||
DISQUES
|
{t("recap.section_disks")}
|
||||||
{disk_warn}
|
{disk_warn}
|
||||||
{disk_text}
|
{disk_text}
|
||||||
|
|
||||||
MATÉRIEL DÉTECTÉ
|
{t("recap.section_hardware")}
|
||||||
• Virtualisation : {virt}
|
{_format_rows(hardware_lines, width)}
|
||||||
• Réseau : {net}
|
{t("recap.gpus_heading")}
|
||||||
Cartes graphiques (drivers installés automatiquement en fin d'install) :
|
|
||||||
{gpu_text}
|
{gpu_text}
|
||||||
|
|
||||||
DÉROULEMENT DE L'INSTALLATION
|
{t("recap.section_steps")}
|
||||||
1. Partitionnement, puis copie du système live FWS (payload LiveOS)
|
1. {t("recap.step_partitioning")}
|
||||||
2. Noyau + initramfs régénérés (mkinitcpio), GRUB installé
|
2. {t("recap.step_kernel")}
|
||||||
3. Bureau choisi + navigateur installés (réseau requis)
|
3. {t("recap.step_desktop")}
|
||||||
4. Matériel : drivers GPU, outils VM, son, Bluetooth, Podman
|
4. {t("recap.step_hardware")}
|
||||||
+ si bureau choisi : {extras}
|
{t("recap.step_hardware_extras", extras=extras)}
|
||||||
|
|
||||||
« Précédent » pour revenir modifier vos choix —
|
{t("recap.footer")}
|
||||||
« Lancer l'installation » pour démarrer réellement l'installation.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@@ -270,9 +295,6 @@ class FWSRecapSpoke(StandaloneSpoke):
|
|||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
StandaloneSpoke.initialize(self)
|
StandaloneSpoke.initialize(self)
|
||||||
# Le bouton « continuer » de CETTE page est le vrai déclencheur :
|
|
||||||
# l'écran suivant (ProgressSpoke) démarre la file d'installation.
|
|
||||||
self.window.get_continue_button().set_label("_Lancer l'installation")
|
|
||||||
|
|
||||||
# Capture pour « Précédent » : initialize() est appelé DEPUIS
|
# Capture pour « Précédent » : initialize() est appelé DEPUIS
|
||||||
# GraphicalUserInterface._on_continue_clicked (clic « Commencer
|
# GraphicalUserInterface._on_continue_clicked (clic « Commencer
|
||||||
@@ -302,7 +324,8 @@ class FWSRecapSpoke(StandaloneSpoke):
|
|||||||
# (à côté de « Quitter » — leur parent est la GtkButtonBox du bas).
|
# (à côté de « Quitter » — leur parent est la GtkButtonBox du bas).
|
||||||
quit_button = self.window.get_quit_button()
|
quit_button = self.window.get_quit_button()
|
||||||
button_box = quit_button.get_parent()
|
button_box = quit_button.get_parent()
|
||||||
self._back_button = Gtk.Button.new_with_mnemonic("_Précédent")
|
# Label set by _set_static_texts() on each display.
|
||||||
|
self._back_button = Gtk.Button(use_underline=True)
|
||||||
self._back_button.connect("clicked", self._on_back_clicked)
|
self._back_button.connect("clicked", self._on_back_clicked)
|
||||||
button_box.add(self._back_button)
|
button_box.add(self._back_button)
|
||||||
# [Quitter, Lancer l'installation, Précédent] -> Précédent au MILIEU,
|
# [Quitter, Lancer l'installation, Précédent] -> Précédent au MILIEU,
|
||||||
@@ -338,8 +361,18 @@ class FWSRecapSpoke(StandaloneSpoke):
|
|||||||
hub.entered.emit(hub)
|
hub.entered.emit(hub)
|
||||||
ui._currentAction = hub
|
ui._currentAction = hub
|
||||||
|
|
||||||
|
def _set_static_texts(self):
|
||||||
|
# Set here rather than in initialize(): the user can go back to the
|
||||||
|
# language screen and pick another language before coming back.
|
||||||
|
self.window.set_property("window-name", t("recap.window_name"))
|
||||||
|
# Le bouton « continuer » de CETTE page est le vrai déclencheur :
|
||||||
|
# l'écran suivant (ProgressSpoke) démarre la file d'installation.
|
||||||
|
self.window.get_continue_button().set_label(t("recap.start_button"))
|
||||||
|
self._back_button.set_label(t("wizard.back"))
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
StandaloneSpoke.refresh(self)
|
StandaloneSpoke.refresh(self)
|
||||||
|
self._set_static_texts()
|
||||||
text = _build_summary()
|
text = _build_summary()
|
||||||
self.builder.get_object("recapView").get_buffer().set_text(text)
|
self.builder.get_object("recapView").get_buffer().set_text(text)
|
||||||
# Copie pour le harnais de debug du .xinitrc (fws-debug.txt).
|
# Copie pour le harnais de debug du .xinitrc (fws-debug.txt).
|
||||||
|
|||||||
Reference in new issue
Block a user