From 55be5f91e0a7cef12f90da1c6f571e65aa44b5d4 Mon Sep 17 00:00:00 2001 From: fkDead Date: Thu, 26 Nov 2026 14:00:07 +0100 Subject: [PATCH] feat(installer): translate the wizard and ask for the desktop last The language picked on the first screen is saved to /tmp/fws-lang, so the live session's dialogs shown after the installer has closed speak it too. --- .../pyanaconda/ui/gui/spokes/fws_wizard.py | 79 ++++++++++++++++--- 1 file changed, 69 insertions(+), 10 deletions(-) diff --git a/configs/baseline/airootfs/usr/lib/python3.14/site-packages/pyanaconda/ui/gui/spokes/fws_wizard.py b/configs/baseline/airootfs/usr/lib/python3.14/site-packages/pyanaconda/ui/gui/spokes/fws_wizard.py index d7c581d..8964ca6 100644 --- a/configs/baseline/airootfs/usr/lib/python3.14/site-packages/pyanaconda/ui/gui/spokes/fws_wizard.py +++ b/configs/baseline/airootfs/usr/lib/python3.14/site-packages/pyanaconda/ui/gui/spokes/fws_wizard.py @@ -50,12 +50,15 @@ # en cas d'échec, on retombe sur le hub classique, l'installation reste possible. # ⚠ Chemin couplé à la version de Python d'Arch (3.14), comme les autres spokes. +import os + import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk from pyanaconda.anaconda_loggers import get_module_logger +from pyanaconda.ui.gui.spokes.fws_i18n import t log = get_module_logger(__name__) @@ -67,18 +70,16 @@ __all__ = [] _WIZARD_ORDER = ( "DatetimeSpoke", # Date et heure "StorageSpoke", # Destination de l'installation (disque) - "FWSDesktopSpoke", # Bureau FWS "UserSpoke", # Compte utilisateur + nom de machine "PasswordSpoke", # Mot de passe administrateur (root) + "FWSDesktopSpoke", # Bureau FWS ) # Le bouton du coin haut-gauche des écrans d'Anaconda s'appelle « Terminé » : # dans un assistant, c'est le bouton « suivant ». -_NEXT_LABEL = "_Suivant" -_BACK_LABEL = "_Précédent" _DONE_BUTTON_NAME = "anaconda-spoke-window-done" - -_WAIT_MSG = "Analyse du matériel en cours, l'écran suivant s'ouvre tout seul…" +# Read by /root/.xinitrc once the installer has closed. +_LANGUAGE_FILE = "/tmp/fws-lang" # Écrans standalone situés JUSTE AVANT le bloc du hub : c'est là que # « Précédent » doit mener depuis la première étape de l'assistant. De là, leur @@ -176,12 +177,49 @@ def _hook_welcome_spoke(): _apply_live_keyboard() except Exception: # pylint: disable=broad-except log.exception("FWS: application du clavier au live impossible.") + # The live session's dialogs shown after the installer has closed + # (/root/.xinitrc) speak this language too, and by then the + # installer's environment is gone: leave it in a file. + try: + with open(_LANGUAGE_FILE, "w", encoding="utf-8") as fh: + fh.write(os.environ.get("LANG", "")) + except OSError: + log.warning("FWS: impossible d'écrire %s.", _LANGUAGE_FILE) spoke_class.apply = apply spoke_class._fws_keyboard_hooked = True log.info("FWS: clavier du live branché sur l'écran de langue.") +def _hook_user_spoke(): + """Translates the host name field that the FWS anaconda package adds. + + That field comes from a patch of user.glade in the anaconda package, so its + texts are in none of Anaconda's catalogs: they come from ours, set on each + display like the FWS screens. + """ + from pyanaconda.ui.gui.spokes import user as user_module + + spoke_class = user_module.UserSpoke + if getattr(spoke_class, "_fws_i18n_hooked", False): + return + + original_refresh = spoke_class.refresh + + def refresh(self, *args, **kwargs): + result = original_refresh(self, *args, **kwargs) + label = self.builder.get_object("hostname_label") + if label is not None: + label.set_text_with_mnemonic(t("user.hostname_label")) + entry = self.builder.get_object("hostname_entry") + if entry is not None: + entry.get_accessible().set_name(t("user.hostname_accessible")) + return result + + spoke_class.refresh = refresh + spoke_class._fws_i18n_hooked = True + + # -------------------------------------------------------------------------- # Assistant : le hub Résumé enchaîne ses écrans au lieu de les proposer # -------------------------------------------------------------------------- @@ -203,6 +241,21 @@ def _really_show(widget): widget.show() +def _follow_language(button, text): + # These buttons are created once per screen, but the user can change the + # language (back to the first screen) before the screen is shown again. + # "map" is emitted each time the screen becomes visible, whatever path led + # there, so the label is re-read from text() at that moment. + def relabel(widget): + label = text() + if widget.get_label() != label: + widget.set_label(label) + + button.set_use_underline(True) + relabel(button) + button.connect("map", relabel) + + def _build_nav_bar(spoke, on_back): """Barre de navigation « Précédent / Suivant » en BAS À DROITE. @@ -236,7 +289,8 @@ def _build_nav_bar(spoke, on_back): box.set_margin_end(6) box.set_margin_bottom(6) - back = Gtk.Button.new_with_mnemonic(_BACK_LABEL) + back = Gtk.Button() + _follow_language(back, lambda: t("wizard.back")) back.connect("clicked", lambda _button: on_back(spoke)) box.add(back) @@ -244,8 +298,7 @@ def _build_nav_bar(spoke, on_back): # La variable Python garde une référence forte : le retrait du GtkGrid # ne peut donc pas détruire le bouton avant qu'on le rattache. window.get_nav_area().remove(done) - done.set_use_underline(True) - done.set_label(_NEXT_LABEL) + _follow_language(done, lambda: t("wizard.next")) box.add(done) window.get_main_box().pack_start(box, False, True, 0) @@ -349,7 +402,8 @@ def add_back_button(spoke, target_class_name): log.warning("FWS: barre de boutons introuvable, « Précédent » non ajouté.") return None - button = Gtk.Button.new_with_mnemonic(_BACK_LABEL) + button = Gtk.Button() + _follow_language(button, lambda: t("wizard.back")) button.connect("clicked", lambda _b: go_back_to_standalone(spoke, target_class_name)) button_box.add(button) @@ -512,7 +566,7 @@ def _install_wizard(): # set_info, elle clignoterait 10 fois par seconde. if getattr(self, "_fws_pending", None) is not spoke: self._fws_pending = spoke - self.set_info(_WAIT_MSG) + self.set_info(t("wizard.wait_hardware_scan")) return self._fws_pending = None @@ -647,6 +701,11 @@ try: except Exception: # pylint: disable=broad-except log.exception("FWS: clavier immédiat non branché (écran de langue inchangé).") +try: + _hook_user_spoke() +except Exception: # pylint: disable=broad-except + log.exception("FWS: champ « nom de machine » laissé non traduit.") + try: _patch_main_window() except Exception: # pylint: disable=broad-except