feat(i18n): translate fws-about

This commit is contained in:
nocode committed 2026-11-26 18:18:27 +01:00
1 parent 02141f8cf4
commit ccc94aad3d
1 file changed
+38 -35
+38 -35
View File
@@ -1,12 +1,14 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# FWS — fenêtre « À propos » : deux onglets, « Le projet FWS » (ce qu'est FWS, # FWS — « About » window: two tabs, « The FWS project » (what FWS is, version,
# version, liens) et « Système » (matériel + logiciel détectés). Remplace le # links) and « System » (detected hardware and software). Replaces the « About
# « About Xfce » de libxfce4ui par une page de marque FWS. GTK3 (python-gobject # Xfce » of libxfce4ui with an FWS-branded page. Texts come from
# installé avec le bureau). # system-translations.toml (about.* keys). GTK3 (python-gobject installed with
# the desktop).
import os import os
import re import re
import subprocess import subprocess
import sys
import gi import gi
@@ -14,6 +16,11 @@ gi.require_version("Gtk", "3.0")
gi.require_version("Gdk", "3.0") # sinon gi charge Gdk 4.0 (conflit avec Gtk3) gi.require_version("Gdk", "3.0") # sinon gi charge Gdk 4.0 (conflit avec Gtk3)
from gi.repository import Gdk, GLib, Gtk # noqa: E402 from gi.repository import Gdk, GLib, Gtk # noqa: E402
sys.path.insert(0, "/usr/local/lib/fws")
from fws_i18n import catalog # noqa: E402
t = catalog("system").t
GLib.set_prgname("fws-about") GLib.set_prgname("fws-about")
@@ -48,7 +55,7 @@ def _cpu():
return line.split(":", 1)[1].strip() return line.split(":", 1)[1].strip()
except OSError: except OSError:
pass pass
return "inconnu" return t("about.unknown")
def _mem(): def _mem():
@@ -57,10 +64,10 @@ def _mem():
for line in fh: for line in fh:
if line.startswith("MemTotal"): if line.startswith("MemTotal"):
kib = int(line.split()[1]) kib = int(line.split()[1])
return f"{kib / 1048576:.1f} Gio" return t("about.memory_size", size=f"{kib / 1048576:.1f}")
except OSError: except OSError:
pass pass
return "inconnu" return t("about.unknown")
def _gpus(): def _gpus():
@@ -69,7 +76,7 @@ def _gpus():
low = line.lower() low = line.lower()
if "vga" in low or "3d" in low or "display" in low: if "vga" in low or "3d" in low or "display" in low:
out.append(line.split(":", 2)[-1].strip()) out.append(line.split(":", 2)[-1].strip())
return out or ["inconnu"] return out or [t("about.unknown")]
def _desktop(): def _desktop():
@@ -77,12 +84,13 @@ def _desktop():
return "Hyprland" return "Hyprland"
env = os.environ.get("XDG_CURRENT_DESKTOP") \ env = os.environ.get("XDG_CURRENT_DESKTOP") \
or os.environ.get("DESKTOP_SESSION") or "" or os.environ.get("DESKTOP_SESSION") or ""
return env or "inconnu" return env or t("about.unknown")
def _session_type(): def _session_type():
t = os.environ.get("XDG_SESSION_TYPE", "") session_type = os.environ.get("XDG_SESSION_TYPE", "")
return {"wayland": "Wayland", "x11": "X11"}.get(t, t or "inconnu") return {"wayland": "Wayland", "x11": "X11"}.get(
session_type, session_type or t("about.unknown"))
def _disks(): def _disks():
@@ -91,7 +99,7 @@ def _disks():
f = line.split() f = line.split()
if f and f[-1] == "disk": if f and f[-1] == "disk":
out.append(" ".join(f[:-1])) out.append(" ".join(f[:-1]))
return out or ["inconnu"] return out or [t("about.unknown")]
def _grid(rows): def _grid(rows):
@@ -114,43 +122,36 @@ def _project_tab(osr):
title.set_markup(f"<span size='xx-large' weight='bold'>{name}</span>") title.set_markup(f"<span size='xx-large' weight='bold'>{name}</span>")
box.pack_start(title, False, False, 0) box.pack_start(title, False, False, 0)
tag = Gtk.Label(label="Une distribution Linux qui ouvre ses bras à tout " tag = Gtk.Label(label=t("about.tagline"))
"le monde : simple dès le premier démarrage, sans "
"rien retirer à Linux — c'est un Arch complet "
"dessous, et tout y reste possible.")
tag.set_line_wrap(True) tag.set_line_wrap(True)
tag.set_max_width_chars(52) tag.set_max_width_chars(52)
box.pack_start(tag, False, False, 0) box.pack_start(tag, False, False, 0)
feats = Gtk.Label() feats = Gtk.Label()
feats.set_markup( feats.set_markup(t("about.features"))
"<b>Inclus :</b> installateur graphique · plusieurs bureaux "
"(GNOME, KDE, Hyprland, i3, XFCE) · Steam &amp; Proton-GE · "
"réalité virtuelle (SteamVR) · PacManager (paquets) · "
"pare-feu · réparation système intégrée.")
feats.set_line_wrap(True) feats.set_line_wrap(True)
feats.set_max_width_chars(52) feats.set_max_width_chars(52)
feats.set_xalign(0) feats.set_xalign(0)
box.pack_start(feats, False, False, 6) box.pack_start(feats, False, False, 6)
home = osr.get("HOME_URL") or "https://gitea.nocode-var.tech/FWS/FWS-ISO" home = osr.get("HOME_URL") or "https://gitea.nocode-var.tech/FWS/FWS-ISO"
link = Gtk.LinkButton.new_with_label(home, "Site du projet") link = Gtk.LinkButton.new_with_label(home, t("about.project_website"))
box.pack_start(link, False, False, 0) box.pack_start(link, False, False, 0)
return box return box
def _system_tab(osr): def _system_tab(osr):
rows = [ rows = [
("Système", osr.get("PRETTY_NAME", "FWS Linux")), (t("about.system_label"), osr.get("PRETTY_NAME", "FWS Linux")),
("Build", osr.get("BUILD_ID", "rolling")), (t("about.build_label"), osr.get("BUILD_ID", "rolling")),
("Noyau", _cmd("uname", "-r") or "inconnu"), (t("about.kernel_label"), _cmd("uname", "-r") or t("about.unknown")),
("Bureau", _desktop()), (t("about.desktop_label"), _desktop()),
("Affichage", _session_type()), (t("about.display_label"), _session_type()),
("Nom de machine", _cmd("hostname") or os.uname().nodename), (t("about.hostname_label"), _cmd("hostname") or os.uname().nodename),
("Processeur", _cpu()), (t("about.processor_label"), _cpu()),
("Mémoire", _mem()), (t("about.memory_label"), _mem()),
("Carte(s) graphique(s)", "\n".join(_gpus())), (t("about.graphics_label"), "\n".join(_gpus())),
("Disque(s)", "\n".join(_disks())), (t("about.disks_label"), "\n".join(_disks())),
] ]
scroll = Gtk.ScrolledWindow() scroll = Gtk.ScrolledWindow()
scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
@@ -160,15 +161,17 @@ def _system_tab(osr):
class AboutWindow(Gtk.Window): class AboutWindow(Gtk.Window):
def __init__(self): def __init__(self):
super().__init__(title="À propos de FWS") super().__init__(title=t("about.window_title"))
self.set_default_size(520, 460) self.set_default_size(520, 460)
self.set_position(Gtk.WindowPosition.CENTER) self.set_position(Gtk.WindowPosition.CENTER)
self.set_type_hint(Gdk.WindowTypeHint.DIALOG) self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
osr = _osrelease() osr = _osrelease()
notebook = Gtk.Notebook() notebook = Gtk.Notebook()
notebook.append_page(_project_tab(osr), Gtk.Label(label="Le projet FWS")) notebook.append_page(_project_tab(osr),
notebook.append_page(_system_tab(osr), Gtk.Label(label="Système")) Gtk.Label(label=t("about.project_tab")))
notebook.append_page(_system_tab(osr),
Gtk.Label(label=t("about.system_tab")))
self.add(notebook) self.add(notebook)
self.connect("destroy", Gtk.main_quit) self.connect("destroy", Gtk.main_quit)