mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-01 19:18:28 -04:00
i18n: cut down terms and sync
port 1.5
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Common
|
||||
import qs.Modals.FileBrowser
|
||||
@@ -21,30 +20,21 @@ Item {
|
||||
property string authPendingApplyPath: ""
|
||||
property bool authShowCustom: false
|
||||
|
||||
readonly property string authAutoLabel: I18n.tr("Auto (recommended)")
|
||||
readonly property string authCustomLabel: I18n.tr("Custom…")
|
||||
readonly property string authAutoLabel: I18n.tr("Auto", "automatic PAM authentication source option")
|
||||
readonly property string authCustomLabel: I18n.tr("Custom...", "custom PAM authentication source option")
|
||||
|
||||
function authServiceLabel(service) {
|
||||
const label = service.name.split("-").map(w => w.charAt(0).toUpperCase() + w.slice(1)).join("-");
|
||||
return service.dir === "/etc/pam.d" ? label : label + " (" + service.dir + ")";
|
||||
}
|
||||
|
||||
readonly property var authOptions: {
|
||||
var opts = [authAutoLabel];
|
||||
for (var i = 0; i < authServices.length; i++)
|
||||
opts.push(authServiceLabel(authServices[i]));
|
||||
opts.push(authCustomLabel);
|
||||
return opts;
|
||||
}
|
||||
readonly property var authOptions: [authAutoLabel, ...authServices.map(s => authServiceLabel(s)), authCustomLabel]
|
||||
|
||||
readonly property string authCurrentValue: {
|
||||
if (SettingsData.lockPamPath === "")
|
||||
return authAutoLabel;
|
||||
for (var i = 0; i < authServices.length; i++) {
|
||||
if (authServices[i].path === SettingsData.lockPamPath)
|
||||
return authServiceLabel(authServices[i]);
|
||||
}
|
||||
return authCustomLabel;
|
||||
const svc = authServices.find(s => s.path === SettingsData.lockPamPath);
|
||||
return svc ? authServiceLabel(svc) : authCustomLabel;
|
||||
}
|
||||
|
||||
function refreshAuthServices() {
|
||||
@@ -61,14 +51,8 @@ Item {
|
||||
}
|
||||
|
||||
function validateAndApplyAuthSource(path) {
|
||||
if (!path || path === "")
|
||||
if (!path)
|
||||
return;
|
||||
if (!path.startsWith("/")) {
|
||||
root.authValidateOk = false;
|
||||
root.authValidateWarn = false;
|
||||
root.authValidateMessage = I18n.tr("Not a valid path");
|
||||
return;
|
||||
}
|
||||
root.authPendingApplyPath = path;
|
||||
root.authValidateMessage = "";
|
||||
root.authValidateOk = false;
|
||||
@@ -81,32 +65,28 @@ Item {
|
||||
function lockFingerprintDescription() {
|
||||
switch (SettingsData.lockFingerprintReason) {
|
||||
case "ready":
|
||||
return SettingsData.enableFprint ? I18n.tr("Authentication changes apply automatically.") : I18n.tr("Use fingerprint authentication for the lock screen.");
|
||||
return I18n.tr("Use fingerprint authentication for the lock screen.", "lock screen fingerprint setting");
|
||||
case "missing_enrollment":
|
||||
if (SettingsData.enableFprint)
|
||||
return I18n.tr("Enabled, but no prints are enrolled yet. Authentication changes apply automatically once you enroll fingerprints.");
|
||||
return I18n.tr("Fingerprint reader detected, but no prints are enrolled yet. You can enable this now and enroll later.");
|
||||
return I18n.tr("Fingerprint reader detected, but no prints are enrolled yet. You can enable this now and enroll later.", "lock screen fingerprint setting");
|
||||
case "missing_reader":
|
||||
return SettingsData.enableFprint ? I18n.tr("Enabled, but no fingerprint reader was detected.") : I18n.tr("No fingerprint reader detected.");
|
||||
return I18n.tr("No fingerprint reader detected.", "fingerprint setting status");
|
||||
case "missing_pam_support":
|
||||
return I18n.tr("Not available — install fprintd and pam_fprintd.");
|
||||
return I18n.tr("Not available — install fprintd and pam_fprintd.", "lock screen fingerprint setting");
|
||||
default:
|
||||
return SettingsData.enableFprint ? I18n.tr("Enabled, but fingerprint availability could not be confirmed.") : I18n.tr("Fingerprint availability could not be confirmed.");
|
||||
return I18n.tr("Fingerprint availability could not be confirmed.", "fingerprint setting status");
|
||||
}
|
||||
}
|
||||
|
||||
function lockU2fDescription() {
|
||||
switch (SettingsData.lockU2fReason) {
|
||||
case "ready":
|
||||
return SettingsData.enableU2f ? I18n.tr("Authentication changes apply automatically.") : I18n.tr("Use a security key for lock screen authentication.", "lock screen U2F security key setting");
|
||||
return I18n.tr("Use a security key for lock screen authentication.", "lock screen U2F security key setting");
|
||||
case "missing_key_registration":
|
||||
if (SettingsData.enableU2f)
|
||||
return I18n.tr("Enabled, but no registered security key was found yet. Authentication changes apply automatically once your key is registered or your U2F config is updated.");
|
||||
return I18n.tr("Security-key support was detected, but no registered key was found yet. You can enable this now and register one later.");
|
||||
return I18n.tr("Security-key support was detected, but no registered key was found yet. You can enable this now and register one later.", "security key setting status");
|
||||
case "missing_pam_support":
|
||||
return I18n.tr("Not available — install or configure pam_u2f.");
|
||||
return I18n.tr("Not available — install or configure pam_u2f.", "lock screen security key setting");
|
||||
default:
|
||||
return SettingsData.enableU2f ? I18n.tr("Enabled, but security-key availability could not be confirmed.") : I18n.tr("Security-key availability could not be confirmed.");
|
||||
return I18n.tr("Security-key availability could not be confirmed.", "security key setting status");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,38 +152,31 @@ Item {
|
||||
|
||||
onExited: exitCode => {
|
||||
root.authValidateRunning = false;
|
||||
var data = null;
|
||||
root.authValidateOk = false;
|
||||
root.authValidateWarn = false;
|
||||
|
||||
let data = null;
|
||||
try {
|
||||
data = JSON.parse(authValidateProcess.collected);
|
||||
} catch (e) {
|
||||
data = null;
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
if (!data) {
|
||||
root.authValidateOk = false;
|
||||
root.authValidateWarn = false;
|
||||
root.authValidateMessage = I18n.tr("Could not run validation. Ensure DMS is installed and dms is in PATH.");
|
||||
root.authValidateMessage = "validation failed — is dms in PATH?";
|
||||
return;
|
||||
}
|
||||
if (data.valid) {
|
||||
SettingsData.set("lockPamPath", root.authPendingApplyPath);
|
||||
SettingsData.set("lockPamInlineFprint", data.inlineFingerprint === true);
|
||||
SettingsData.set("lockPamInlineU2f", data.inlineU2f === true);
|
||||
const warns = Array.isArray(data.warnings) ? data.warnings : [];
|
||||
root.authValidateOk = true;
|
||||
root.authValidateWarn = warns.length > 0;
|
||||
root.authValidateMessage = warns.length > 0 ? (I18n.tr("Applied with warnings:") + "\n" + warns.join("\n")) : I18n.tr("Applied successfully.");
|
||||
} else {
|
||||
root.authValidateOk = false;
|
||||
root.authValidateWarn = false;
|
||||
if (!data.valid) {
|
||||
const errs = Array.isArray(data.errors) ? data.errors : [];
|
||||
const missing = Array.isArray(data.missingModules) ? data.missingModules : [];
|
||||
var msg = I18n.tr("Invalid — not applied.");
|
||||
if (errs.length > 0)
|
||||
msg = msg + "\n" + errs.join("\n");
|
||||
if (missing.length > 0)
|
||||
msg = msg + "\n" + I18n.tr("Missing modules: ") + missing.join(", ");
|
||||
root.authValidateMessage = msg;
|
||||
root.authValidateMessage = ["not applied:", ...errs].join("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
SettingsData.set("lockPamPath", root.authPendingApplyPath);
|
||||
SettingsData.set("lockPamInlineFprint", data.inlineFingerprint === true);
|
||||
SettingsData.set("lockPamInlineU2f", data.inlineU2f === true);
|
||||
const warns = Array.isArray(data.warnings) ? data.warnings : [];
|
||||
root.authValidateOk = true;
|
||||
root.authValidateWarn = warns.length > 0;
|
||||
root.authValidateMessage = warns.length > 0 ? ["applied with warnings:", ...warns].join("\n") : "applied";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,22 +326,14 @@ Item {
|
||||
SettingsCard {
|
||||
width: parent.width
|
||||
iconName: "key"
|
||||
title: I18n.tr("Authentication Source")
|
||||
title: "Authentication Source"
|
||||
settingKey: "lockAuthSource"
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Auto resolves the system auth stack automatically. Picking a source pins the lock screen to that PAM file.")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
width: parent.width
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
SettingsDropdownRow {
|
||||
settingKey: "lockPamPath"
|
||||
tags: ["lock", "screen", "pam", "authentication", "source", "service"]
|
||||
text: I18n.tr("Authentication Source")
|
||||
description: SettingsData.lockPamPath !== "" ? I18n.tr("Pinned to ") + SettingsData.lockPamPath : I18n.tr("Which PAM service the lock screen uses to authenticate")
|
||||
text: "Authentication Source"
|
||||
description: SettingsData.lockPamPath !== "" ? SettingsData.lockPamPath : "Which PAM service the lock screen uses to authenticate"
|
||||
options: root.authOptions
|
||||
currentValue: root.authCurrentValue
|
||||
onValueChanged: value => {
|
||||
@@ -382,43 +347,30 @@ Item {
|
||||
return;
|
||||
}
|
||||
root.authShowCustom = false;
|
||||
var svc = root.authServices.find(s => root.authServiceLabel(s) === value);
|
||||
const svc = root.authServices.find(s => root.authServiceLabel(s) === value);
|
||||
if (svc)
|
||||
root.validateAndApplyAuthSource(svc.path);
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
Row {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingS
|
||||
visible: root.authShowCustom || root.authCurrentValue === root.authCustomLabel
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Enter the absolute path to a PAM service file, then validate and apply.")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
width: parent.width
|
||||
wrapMode: Text.Wrap
|
||||
DankTextField {
|
||||
id: customPamField
|
||||
width: parent.width - validatePamButton.width - Theme.spacingS
|
||||
placeholderText: "/etc/pam.d/my-service"
|
||||
text: SettingsData.lockPamPath
|
||||
backgroundColor: Theme.surfaceContainerHighest
|
||||
}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingS
|
||||
|
||||
DankTextField {
|
||||
id: customPamField
|
||||
width: parent.width - validatePamButton.width - Theme.spacingS
|
||||
placeholderText: "/etc/pam.d/my-service"
|
||||
text: SettingsData.lockPamPath
|
||||
backgroundColor: Theme.surfaceContainerHighest
|
||||
}
|
||||
|
||||
DankButton {
|
||||
id: validatePamButton
|
||||
text: I18n.tr("Validate & Apply")
|
||||
enabled: !root.authValidateRunning && customPamField.text.trim() !== ""
|
||||
onClicked: root.validateAndApplyAuthSource(customPamField.text.trim())
|
||||
}
|
||||
DankButton {
|
||||
id: validatePamButton
|
||||
text: I18n.tr("Apply Changes", "validate and apply custom PAM authentication source")
|
||||
enabled: !root.authValidateRunning && customPamField.text.trim() !== ""
|
||||
onClicked: root.validateAndApplyAuthSource(customPamField.text.trim())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,7 +396,7 @@ Item {
|
||||
|
||||
StyledText {
|
||||
visible: (SettingsData.lockPamInlineFprint && SettingsData.enableFprint) || (SettingsData.lockPamInlineU2f && SettingsData.enableU2f)
|
||||
text: I18n.tr("The chosen PAM stack already prompts for fingerprint or security key, so DMS's separate prompts are suppressed to avoid a double prompt.")
|
||||
text: "The pinned PAM stack already prompts for fingerprint or security key, so DMS skips its own prompts"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.warning
|
||||
width: parent.width
|
||||
|
||||
Reference in New Issue
Block a user