feat(sddm): show the login screen in the system's language
This commit is contained in:
1 file changed
+57
-12
@@ -8,6 +8,9 @@
|
|||||||
// surchargé par theme.conf.user écrit par le %post : accent selon le DE).
|
// surchargé par theme.conf.user écrit par le %post : accent selon le DE).
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls.Basic
|
import QtQuick.Controls.Basic
|
||||||
|
// Texts by language, written at build time from system-translations.toml
|
||||||
|
// (sddm.* keys) by /usr/local/lib/fws/translate-static-files.py.
|
||||||
|
import "translations.js" as Translations
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
@@ -17,6 +20,46 @@ Rectangle {
|
|||||||
readonly property color accent: config.accent || "#3daee9"
|
readonly property color accent: config.accent || "#3daee9"
|
||||||
readonly property color fieldBg: "#2a2a44"
|
readonly property color fieldBg: "#2a2a44"
|
||||||
|
|
||||||
|
// The greeter's locale comes from the system's (/etc/locale.conf).
|
||||||
|
readonly property var languages: languageCandidates()
|
||||||
|
|
||||||
|
function languageCandidates() {
|
||||||
|
const names = Qt.locale().uiLanguages.concat([Qt.locale().name])
|
||||||
|
const out = []
|
||||||
|
for (let i = 0; i < names.length; i++) {
|
||||||
|
const parts = names[i].replace(/-/g, "_").split("_")
|
||||||
|
const language = parts[0]
|
||||||
|
let territory = "", modifier = ""
|
||||||
|
for (let j = 1; j < parts.length; j++) {
|
||||||
|
// A four-letter part is a script: only Latin Serbian has its
|
||||||
|
// own catalog entry (sr@latin, Cyrillic being plain sr).
|
||||||
|
if (parts[j].length === 4)
|
||||||
|
modifier = parts[j] === "Latn" ? "@latin" : ""
|
||||||
|
else
|
||||||
|
territory = parts[j]
|
||||||
|
}
|
||||||
|
if (territory)
|
||||||
|
out.push(language + "_" + territory + modifier)
|
||||||
|
out.push(language + modifier)
|
||||||
|
if (modifier) {
|
||||||
|
if (territory)
|
||||||
|
out.push(language + "_" + territory)
|
||||||
|
out.push(language)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.push("en")
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
function t(key) {
|
||||||
|
const texts = Translations.messages[key]
|
||||||
|
if (texts)
|
||||||
|
for (let i = 0; i < languages.length; i++)
|
||||||
|
if (texts[languages[i]])
|
||||||
|
return texts[languages[i]]
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
|
||||||
gradient: Gradient {
|
gradient: Gradient {
|
||||||
GradientStop { position: 0.0; color: config.colorTop || "#1a1a2e" }
|
GradientStop { position: 0.0; color: config.colorTop || "#1a1a2e" }
|
||||||
GradientStop { position: 1.0; color: config.colorBottom || "#16213e" }
|
GradientStop { position: 1.0; color: config.colorBottom || "#16213e" }
|
||||||
@@ -25,7 +68,7 @@ Rectangle {
|
|||||||
Connections {
|
Connections {
|
||||||
target: sddm
|
target: sddm
|
||||||
function onLoginFailed() {
|
function onLoginFailed() {
|
||||||
errorLabel.text = "Échec de la connexion — vérifiez le mot de passe"
|
errorLabel.text = t("sddm.login_failed")
|
||||||
passwordField.text = ""
|
passwordField.text = ""
|
||||||
passwordField.forceActiveFocus()
|
passwordField.forceActiveFocus()
|
||||||
}
|
}
|
||||||
@@ -45,9 +88,12 @@ Rectangle {
|
|||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
var now = new Date()
|
const now = new Date()
|
||||||
clockLabel.text = Qt.formatTime(now, "hh:mm")
|
clockLabel.text = now.toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
|
||||||
dateLabel.text = Qt.formatDate(now, "dddd d MMMM yyyy")
|
// Only the first letter is raised: capitalizing every word gives
|
||||||
|
// "26 Ноября" or "26 Novembre", where months are lowercase.
|
||||||
|
const date = now.toLocaleDateString(Qt.locale(), Locale.LongFormat)
|
||||||
|
dateLabel.text = date.charAt(0).toLocaleUpperCase() + date.slice(1)
|
||||||
}
|
}
|
||||||
Component.onCompleted: triggered()
|
Component.onCompleted: triggered()
|
||||||
}
|
}
|
||||||
@@ -70,7 +116,6 @@ Rectangle {
|
|||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
color: "#a0a0b8"
|
color: "#a0a0b8"
|
||||||
font.pixelSize: 20
|
font.pixelSize: 20
|
||||||
font.capitalization: Font.Capitalize
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +139,7 @@ Rectangle {
|
|||||||
|
|
||||||
Text {
|
Text {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
text: config.greeting || "Bienvenue sur FWS"
|
text: config.greeting || t("sddm.greeting")
|
||||||
color: "#f0f0f5"
|
color: "#f0f0f5"
|
||||||
font.pixelSize: 22
|
font.pixelSize: 22
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
@@ -107,7 +152,7 @@ Rectangle {
|
|||||||
id: userField
|
id: userField
|
||||||
width: parent.width
|
width: parent.width
|
||||||
text: userModel.lastUser
|
text: userModel.lastUser
|
||||||
placeholderText: "Utilisateur"
|
placeholderText: t("sddm.username")
|
||||||
placeholderTextColor: "#7d7d95"
|
placeholderTextColor: "#7d7d95"
|
||||||
color: "#f0f0f5"
|
color: "#f0f0f5"
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
@@ -124,7 +169,7 @@ Rectangle {
|
|||||||
TextField {
|
TextField {
|
||||||
id: passwordField
|
id: passwordField
|
||||||
width: parent.width
|
width: parent.width
|
||||||
placeholderText: "Mot de passe"
|
placeholderText: t("sddm.password")
|
||||||
placeholderTextColor: "#7d7d95"
|
placeholderTextColor: "#7d7d95"
|
||||||
color: "#f0f0f5"
|
color: "#f0f0f5"
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
@@ -143,7 +188,7 @@ Rectangle {
|
|||||||
Text {
|
Text {
|
||||||
visible: keyboard.capsLock
|
visible: keyboard.capsLock
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
text: "⚠ Verrouillage majuscules activé"
|
text: "⚠ " + t("sddm.caps_lock")
|
||||||
color: "#e6c07b"
|
color: "#e6c07b"
|
||||||
font.pixelSize: 13
|
font.pixelSize: 13
|
||||||
}
|
}
|
||||||
@@ -163,7 +208,7 @@ Rectangle {
|
|||||||
height: 44
|
height: 44
|
||||||
onClicked: doLogin()
|
onClicked: doLogin()
|
||||||
contentItem: Text {
|
contentItem: Text {
|
||||||
text: "Se connecter"
|
text: t("sddm.login_button")
|
||||||
color: "#ffffff"
|
color: "#ffffff"
|
||||||
font.pixelSize: 16
|
font.pixelSize: 16
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
@@ -233,8 +278,8 @@ Rectangle {
|
|||||||
anchors.margins: 24
|
anchors.margins: 24
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
PowerButton { label: "Redémarrer"; onClicked: sddm.reboot() }
|
PowerButton { label: t("sddm.reboot"); onClicked: sddm.reboot() }
|
||||||
PowerButton { label: "Éteindre"; onClicked: sddm.powerOff() }
|
PowerButton { label: t("sddm.power_off"); onClicked: sddm.powerOff() }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nom de la machine, discret, en bas à gauche.
|
// Nom de la machine, discret, en bas à gauche.
|
||||||
|
|||||||
Reference in new issue
Block a user