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
# FWS — fenêtre « À propos » : deux onglets, « Le projet FWS » (ce qu'est FWS,
# version, liens) et « Système » (matériel + logiciel détectés). Remplace le
# « About Xfce » de libxfce4ui par une page de marque FWS. GTK3 (python-gobject
# installé avec le bureau).
# FWS — « About » window: two tabs, « The FWS project » (what FWS is, version,
# links) and « System » (detected hardware and software). Replaces the « About
# Xfce » of libxfce4ui with an FWS-branded page. Texts come from
# system-translations.toml (about.* keys). GTK3 (python-gobject installed with
# the desktop).
import os
import re
import subprocess
import sys
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)
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")
@@ -48,7 +55,7 @@ def _cpu():
return line.split(":", 1)[1].strip()
except OSError:
pass
return "inconnu"
return t("about.unknown")
def _mem():
@@ -57,10 +64,10 @@ def _mem():
for line in fh:
if line.startswith("MemTotal"):
kib = int(line.split()[1])
return f"{kib / 1048576:.1f} Gio"
return t("about.memory_size", size=f"{kib / 1048576:.1f}")
except OSError:
pass
return "inconnu"
return t("about.unknown")
def _gpus():
@@ -69,7 +76,7 @@ def _gpus():
low = line.lower()
if "vga" in low or "3d" in low or "display" in low:
out.append(line.split(":", 2)[-1].strip())
return out or ["inconnu"]
return out or [t("about.unknown")]
def _desktop():
@@ -77,12 +84,13 @@ def _desktop():
return "Hyprland"
env = os.environ.get("XDG_CURRENT_DESKTOP") \
or os.environ.get("DESKTOP_SESSION") or ""
return env or "inconnu"
return env or t("about.unknown")
def _session_type():
t = os.environ.get("XDG_SESSION_TYPE", "")
return {"wayland": "Wayland", "x11": "X11"}.get(t, t or "inconnu")
session_type = os.environ.get("XDG_SESSION_TYPE", "")
return {"wayland": "Wayland", "x11": "X11"}.get(
session_type, session_type or t("about.unknown"))
def _disks():
@@ -91,7 +99,7 @@ def _disks():
f = line.split()
if f and f[-1] == "disk":
out.append(" ".join(f[:-1]))
return out or ["inconnu"]
return out or [t("about.unknown")]
def _grid(rows):
@@ -114,43 +122,36 @@ def _project_tab(osr):
title.set_markup(f"<span size='xx-large' weight='bold'>{name}</span>")
box.pack_start(title, False, False, 0)
tag = Gtk.Label(label="Une distribution Linux qui ouvre ses bras à tout "
"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 = Gtk.Label(label=t("about.tagline"))
tag.set_line_wrap(True)
tag.set_max_width_chars(52)
box.pack_start(tag, False, False, 0)
feats = Gtk.Label()
feats.set_markup(
"<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_markup(t("about.features"))
feats.set_line_wrap(True)
feats.set_max_width_chars(52)
feats.set_xalign(0)
box.pack_start(feats, False, False, 6)
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)
return box
def _system_tab(osr):
rows = [
("Système", osr.get("PRETTY_NAME", "FWS Linux")),
("Build", osr.get("BUILD_ID", "rolling")),
("Noyau", _cmd("uname", "-r") or "inconnu"),
("Bureau", _desktop()),
("Affichage", _session_type()),
("Nom de machine", _cmd("hostname") or os.uname().nodename),
("Processeur", _cpu()),
("Mémoire", _mem()),
("Carte(s) graphique(s)", "\n".join(_gpus())),
("Disque(s)", "\n".join(_disks())),
(t("about.system_label"), osr.get("PRETTY_NAME", "FWS Linux")),
(t("about.build_label"), osr.get("BUILD_ID", "rolling")),
(t("about.kernel_label"), _cmd("uname", "-r") or t("about.unknown")),
(t("about.desktop_label"), _desktop()),
(t("about.display_label"), _session_type()),
(t("about.hostname_label"), _cmd("hostname") or os.uname().nodename),
(t("about.processor_label"), _cpu()),
(t("about.memory_label"), _mem()),
(t("about.graphics_label"), "\n".join(_gpus())),
(t("about.disks_label"), "\n".join(_disks())),
]
scroll = Gtk.ScrolledWindow()
scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
@@ -160,15 +161,17 @@ def _system_tab(osr):
class AboutWindow(Gtk.Window):
def __init__(self):
super().__init__(title="À propos de FWS")
super().__init__(title=t("about.window_title"))
self.set_default_size(520, 460)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
osr = _osrelease()
notebook = Gtk.Notebook()
notebook.append_page(_project_tab(osr), Gtk.Label(label="Le projet FWS"))
notebook.append_page(_system_tab(osr), Gtk.Label(label="Système"))
notebook.append_page(_project_tab(osr),
Gtk.Label(label=t("about.project_tab")))
notebook.append_page(_system_tab(osr),
Gtk.Label(label=t("about.system_tab")))
self.add(notebook)
self.connect("destroy", Gtk.main_quit)