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.
This commit is contained in:
1 file changed
+69
-10
+69
-10
@@ -50,12 +50,15 @@
|
|||||||
# en cas d'échec, on retombe sur le hub classique, l'installation reste possible.
|
# 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.
|
# ⚠ Chemin couplé à la version de Python d'Arch (3.14), comme les autres spokes.
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
|
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
from pyanaconda.anaconda_loggers import get_module_logger
|
from pyanaconda.anaconda_loggers import get_module_logger
|
||||||
|
from pyanaconda.ui.gui.spokes.fws_i18n import t
|
||||||
|
|
||||||
log = get_module_logger(__name__)
|
log = get_module_logger(__name__)
|
||||||
|
|
||||||
@@ -67,18 +70,16 @@ __all__ = []
|
|||||||
_WIZARD_ORDER = (
|
_WIZARD_ORDER = (
|
||||||
"DatetimeSpoke", # Date et heure
|
"DatetimeSpoke", # Date et heure
|
||||||
"StorageSpoke", # Destination de l'installation (disque)
|
"StorageSpoke", # Destination de l'installation (disque)
|
||||||
"FWSDesktopSpoke", # Bureau FWS
|
|
||||||
"UserSpoke", # Compte utilisateur + nom de machine
|
"UserSpoke", # Compte utilisateur + nom de machine
|
||||||
"PasswordSpoke", # Mot de passe administrateur (root)
|
"PasswordSpoke", # Mot de passe administrateur (root)
|
||||||
|
"FWSDesktopSpoke", # Bureau FWS
|
||||||
)
|
)
|
||||||
|
|
||||||
# Le bouton du coin haut-gauche des écrans d'Anaconda s'appelle « Terminé » :
|
# Le bouton du coin haut-gauche des écrans d'Anaconda s'appelle « Terminé » :
|
||||||
# dans un assistant, c'est le bouton « suivant ».
|
# dans un assistant, c'est le bouton « suivant ».
|
||||||
_NEXT_LABEL = "_Suivant"
|
|
||||||
_BACK_LABEL = "_Précédent"
|
|
||||||
_DONE_BUTTON_NAME = "anaconda-spoke-window-done"
|
_DONE_BUTTON_NAME = "anaconda-spoke-window-done"
|
||||||
|
# Read by /root/.xinitrc once the installer has closed.
|
||||||
_WAIT_MSG = "Analyse du matériel en cours, l'écran suivant s'ouvre tout seul…"
|
_LANGUAGE_FILE = "/tmp/fws-lang"
|
||||||
|
|
||||||
# Écrans standalone situés JUSTE AVANT le bloc du hub : c'est là que
|
# É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
|
# « 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()
|
_apply_live_keyboard()
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
log.exception("FWS: application du clavier au live impossible.")
|
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.apply = apply
|
||||||
spoke_class._fws_keyboard_hooked = True
|
spoke_class._fws_keyboard_hooked = True
|
||||||
log.info("FWS: clavier du live branché sur l'écran de langue.")
|
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
|
# Assistant : le hub Résumé enchaîne ses écrans au lieu de les proposer
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
@@ -203,6 +241,21 @@ def _really_show(widget):
|
|||||||
widget.show()
|
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):
|
def _build_nav_bar(spoke, on_back):
|
||||||
"""Barre de navigation « Précédent / Suivant » en BAS À DROITE.
|
"""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_end(6)
|
||||||
box.set_margin_bottom(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))
|
back.connect("clicked", lambda _button: on_back(spoke))
|
||||||
box.add(back)
|
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
|
# 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.
|
# ne peut donc pas détruire le bouton avant qu'on le rattache.
|
||||||
window.get_nav_area().remove(done)
|
window.get_nav_area().remove(done)
|
||||||
done.set_use_underline(True)
|
_follow_language(done, lambda: t("wizard.next"))
|
||||||
done.set_label(_NEXT_LABEL)
|
|
||||||
box.add(done)
|
box.add(done)
|
||||||
|
|
||||||
window.get_main_box().pack_start(box, False, True, 0)
|
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é.")
|
log.warning("FWS: barre de boutons introuvable, « Précédent » non ajouté.")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
button = Gtk.Button.new_with_mnemonic(_BACK_LABEL)
|
button = Gtk.Button()
|
||||||
|
_follow_language(button, lambda: t("wizard.back"))
|
||||||
button.connect("clicked",
|
button.connect("clicked",
|
||||||
lambda _b: go_back_to_standalone(spoke, target_class_name))
|
lambda _b: go_back_to_standalone(spoke, target_class_name))
|
||||||
button_box.add(button)
|
button_box.add(button)
|
||||||
@@ -512,7 +566,7 @@ def _install_wizard():
|
|||||||
# set_info, elle clignoterait 10 fois par seconde.
|
# set_info, elle clignoterait 10 fois par seconde.
|
||||||
if getattr(self, "_fws_pending", None) is not spoke:
|
if getattr(self, "_fws_pending", None) is not spoke:
|
||||||
self._fws_pending = spoke
|
self._fws_pending = spoke
|
||||||
self.set_info(_WAIT_MSG)
|
self.set_info(t("wizard.wait_hardware_scan"))
|
||||||
return
|
return
|
||||||
|
|
||||||
self._fws_pending = None
|
self._fws_pending = None
|
||||||
@@ -647,6 +701,11 @@ try:
|
|||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
log.exception("FWS: clavier immédiat non branché (écran de langue inchangé).")
|
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:
|
try:
|
||||||
_patch_main_window()
|
_patch_main_window()
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
|
|||||||
Reference in new issue
Block a user