translations: update qsTrs to Translation.tr and allow translation of notifications

This commit is contained in:
end-4
2025-07-17 13:56:50 +07:00
parent 9ca67f0095
commit 1e7c84a6c1
10 changed files with 104 additions and 41 deletions
+5 -5
View File
@@ -169,7 +169,7 @@ Scope {
ScrollHint {
reveal: barLeftSideMouseArea.hovered
icon: "light_mode"
tooltipText: qsTr("Scroll to change brightness")
tooltipText: Translation.tr("Scroll to change brightness")
side: "left"
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
@@ -380,7 +380,7 @@ Scope {
ScrollHint {
reveal: barRightSideMouseArea.hovered
icon: "volume_up"
tooltipText: qsTr("Scroll to change volume")
tooltipText: Translation.tr("Scroll to change volume")
side: "right"
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
@@ -586,7 +586,7 @@ Scope {
GlobalShortcut {
name: "barToggle"
description: qsTr("Toggles bar on press")
description: Translation.tr("Toggles bar on press")
onPressed: {
GlobalStates.barOpen = !GlobalStates.barOpen;
@@ -595,7 +595,7 @@ Scope {
GlobalShortcut {
name: "barOpen"
description: qsTr("Opens bar on press")
description: Translation.tr("Opens bar on press")
onPressed: {
GlobalStates.barOpen = true;
@@ -604,7 +604,7 @@ Scope {
GlobalShortcut {
name: "barClose"
description: qsTr("Closes bar on press")
description: Translation.tr("Closes bar on press")
onPressed: {
GlobalStates.barOpen = false;
@@ -19,11 +19,11 @@ Scope { // Scope
property var tabButtonList: [
{
"icon": "keyboard",
"name": qsTr("Keybinds")
"name": Translation.tr("Keybinds")
},
{
"icon": "experiment",
"name": qsTr("Elements")
"name": Translation.tr("Elements")
},
]
property int selectedTab: 0
@@ -59,7 +59,7 @@ Singleton {
}
property JsonObject ai: JsonObject {
property string systemPrompt: qsTr("## Style\n- Use casual tone, don't be formal! Make sure you answer precisely without hallucination and prefer bullet points over walls of text. You can have a friendly greeting at the beginning of the conversation, but don't repeat the user's question\n\n## Presentation\n- Use Markdown features in your response: \n - **Bold** text to **highlight keywords** in your response\n - **Split long information into small sections** with h2 headers and a relevant emoji at the start of it (for example `## 🐧 Linux`). Bullet points are preferred over long paragraphs, unless you're offering writing support or instructed otherwise by the user.\n- Asked to compare different options? You should firstly use a table to compare the main aspects, then elaborate or include relevant comments from online forums *after* the table. Make sure to provide a final recommendation for the user's use case!\n- Use LaTeX formatting for mathematical and scientific notations whenever appropriate. Enclose all LaTeX '$$' delimiters. NEVER generate LaTeX code in a latex block unless the user explicitly asks for it. DO NOT use LaTeX for regular documents (resumes, letters, essays, CVs, etc.).\n\nThanks!\n\n## Tools\nMay or may not be available depending on the user's settings. If they're available, follow these guidelines:\n\n### Search\n- When user asks for information that might benefit from up-to-date information, use this to get search access\n\n### Shell configuration\n- Always fetch the config options to see the available keys before setting\n- Avoid unnecessarily asking the user to confirm the changes they explicitly asked for, just do it\n")
property string systemPrompt: "## Style\n- Use casual tone, don't be formal! Make sure you answer precisely without hallucination and prefer bullet points over walls of text. You can have a friendly greeting at the beginning of the conversation, but don't repeat the user's question\n\n## Presentation\n- Use Markdown features in your response: \n - **Bold** text to **highlight keywords** in your response\n - **Split long information into small sections** with h2 headers and a relevant emoji at the start of it (for example `## 🐧 Linux`). Bullet points are preferred over long paragraphs, unless you're offering writing support or instructed otherwise by the user.\n- Asked to compare different options? You should firstly use a table to compare the main aspects, then elaborate or include relevant comments from online forums *after* the table. Make sure to provide a final recommendation for the user's use case!\n- Use LaTeX formatting for mathematical and scientific notations whenever appropriate. Enclose all LaTeX '$$' delimiters. NEVER generate LaTeX code in a latex block unless the user explicitly asks for it. DO NOT use LaTeX for regular documents (resumes, letters, essays, CVs, etc.).\n\nThanks!\n\n## Tools\nMay or may not be available depending on the user's settings. If they're available, follow these guidelines:\n\n### Search\n- When user asks for information that might benefit from up-to-date information, use this to get search access\n\n### Shell configuration\n- Always fetch the config options to see the available keys before setting\n- Avoid unnecessarily asking the user to confirm the changes they explicitly asked for, just do it\n"
}
property JsonObject appearance: JsonObject {
@@ -99,7 +99,11 @@ ColumnLayout {
Quickshell.execDetached(["bash", "-c",
`echo '${StringUtils.shellSingleQuoteEscape(segmentContent)}' > '${downloadPath}/code.${segmentLang || "txt"}'`
])
Quickshell.execDetached(["bash", "-c", `notify-send 'Code saved to file' '${downloadPath}/code.${segmentLang || "txt"}' -a Shell`])
Quickshell.execDetached(["notify-send",
Translation.tr("Code saved to file"),
Translation.tr("Saved to %1").arg(`${downloadPath}/code.${segmentLang || "txt"}`),
"-a", "Shell"
])
saveCodeButton.activated = true
saveIconTimer.restart()
}
@@ -181,7 +181,7 @@ Button {
onClicked: {
root.showActions = false
Quickshell.execDetached(["bash", "-c",
`curl '${root.imageData.file_url}' -o '${root.imageData.is_nsfw ? root.nsfwPath : root.downloadPath}/${root.fileName}' && notify-send '${qsTr("Download complete")}' '${root.downloadPath}/${root.fileName}' -a 'Shell'`
`curl '${root.imageData.file_url}' -o '${root.imageData.is_nsfw ? root.nsfwPath : root.downloadPath}/${root.fileName}' && notify-send '${Translation.tr("Download complete")}' '${root.downloadPath}/${root.fileName}' -a 'Shell'`
])
}
}
@@ -40,7 +40,11 @@ QuickToggleButton {
command: ["warp-cli", "connect"]
onExited: (exitCode, exitStatus) => {
if (exitCode !== 0) {
Quickshell.execDetached(["notify-send", "Cloudflare WARP", "Connection failed. Please inspect manually with the <tt>warp-cli</tt> command", "-a", "Shell"])
Quickshell.execDetached(["notify-send",
Translation.tr("Cloudflare WARP"),
Translation.tr("Connection failed. Please inspect manually with the <tt>warp-cli</tt> command")
, "-a", "Shell"
])
}
}
}
@@ -53,7 +57,11 @@ QuickToggleButton {
if (exitCode === 0) {
connectProc.running = true
} else {
Quickshell.execDetached(["notify-send", "Cloudflare WARP", "Registration failed. Please inspect manually with the <tt>warp-cli</tt> command", "-a", "Shell"])
Quickshell.execDetached(["notify-send",
Translation.tr("Cloudflare WARP"),
Translation.tr("Registration failed. Please inspect manually with the <tt>warp-cli</tt> command"),
"-a", "Shell"
])
}
}
}
@@ -80,6 +88,6 @@ QuickToggleButton {
}
}
StyledToolTip {
content: qsTr("Cloudflare WARP (1.1.1.1)")
content: Translation.tr("Cloudflare WARP (1.1.1.1)")
}
}
+15 -4
View File
@@ -23,13 +23,24 @@ Singleton {
property bool isSuspendingAndNotCharging: allowAutomaticSuspend && isSuspending && !isCharging
onIsLowAndNotChargingChanged: {
if (available && isLowAndNotCharging)
Quickshell.execDetached(["bash", "-c", `notify-send "Low battery" "Consider plugging in your device" -u critical -a "Shell"`]);
if (available && isLowAndNotCharging) Quickshell.execDetached([
"notify-send",
Translation.tr("Low battery"),
Translation.tr("Consider plugging in your device"),
"-u", "critical",
"-a", "Shell"
])
}
onIsCriticalAndNotChargingChanged: {
if (available && isCriticalAndNotCharging)
Quickshell.execDetached(["bash", "-c", `notify-send "Critically low battery" "🙏 I beg for pleas charg\nAutomatic suspend triggers at ${Config.options.battery.suspend}%" -u critical -a "Shell"`]);
if (available && isCriticalAndNotCharging) Quickshell.execDetached([
"notify-send",
Translation.tr("Critically low battery"),
Translation.tr("Please charge!\nAutomatic suspend triggers at %1").arg(Config.options.battery.suspend),
"-u", "critical",
"-a", "Shell"
]);
}
onIsSuspendingAndNotChargingChanged: {
+19 -20
View File
@@ -17,25 +17,25 @@ Singleton {
property bool gpsActive: Config.options.bar.weather.enableGPS
property var location: ({
valid: false,
lat: 0,
lon: 0
})
valid: false,
lat: 0,
lon: 0
})
property var data: ({
uv: 0,
humidity: 0,
sunrise: 0,
sunset: 0,
windDir: 0,
wCode: 0,
city: 0,
wind: 0,
precip: 0,
visib: 0,
press: 0,
temp: 0
})
uv: 0,
humidity: 0,
sunrise: 0,
sunset: 0,
windDir: 0,
wCode: 0,
city: 0,
wind: 0,
precip: 0,
visib: 0,
press: 0,
temp: 0
})
function refineData(data) {
let temp = {};
@@ -90,8 +90,7 @@ Singleton {
}
Component.onCompleted: {
if (!root.gpsActive)
return;
if (!root.gpsActive) return;
console.info("[WeatherService] Starting the GPS service.");
positionSource.start();
}
@@ -139,7 +138,7 @@ Singleton {
positionSource.stop();
root.location.valid = false;
root.gpsActive = false;
Quickshell.execDetached(["bash", "-c", `notify-send WeatherService 'Can not find a GPS service. Using the fallback method instead.'`]);
Quickshell.execDetached(["notify-send", Translation.tr("Weather Service"), Translation.tr("Cannot find a GPS service. Using the fallback method instead."), "-a", "Shell"]);
console.error("[WeatherService] Could not aquire a valid backend plugin.");
}
}
+24 -2
View File
@@ -315,6 +315,28 @@
"%1 notifications": "%1 notifications",
"Load chat from %1": "Load chat from %1",
"Load prompt from %1": "Load prompt from %1",
"Online models disallowed for \n\nControlled by `policies.ai` config option": "Online models disallowed for \n\nControlled by `policies.ai` config option",
"Save chat to %1": "Save chat to %1"
"Save chat to %1": "Save chat to %1",
"Weather Service": "Weather Service",
"Cannot find a GPS service. Using the fallback method instead.": "Cannot find a GPS service. Using the fallback method instead.",
"Critically low battery": "Critically low battery",
"Select output device": "Select output device",
"Code saved to file": "Code saved to file",
"Online models disallowed\n\nControlled by `policies.ai` config option": "Online models disallowed\n\nControlled by `policies.ai` config option",
"Opens bar on press": "Opens bar on press",
"Scroll to change volume": "Scroll to change volume",
"Toggles bar on press": "Toggles bar on press",
"Elements": "Elements",
"%1 • %2 tasks": "%1 • %2 tasks",
"Download complete": "Download complete",
"Please charge!\nAutomatic suspend triggers at %1": "Please charge!\nAutomatic suspend triggers at %1",
"Cloudflare WARP": "Cloudflare WARP",
"Cloudflare WARP (1.1.1.1)": "Cloudflare WARP (1.1.1.1)",
"Closes bar on press": "Closes bar on press",
"Scroll to change brightness": "Scroll to change brightness",
"Connection failed. Please inspect manually with the <tt>warp-cli</tt> command": "Connection failed. Please inspect manually with the <tt>warp-cli</tt> command",
"Select input device": "Select input device",
"Registration failed. Please inspect manually with the <tt>warp-cli</tt> command": "Registration failed. Please inspect manually with the <tt>warp-cli</tt> command",
"Consider plugging in your device": "Consider plugging in your device",
"Low battery": "Low battery",
"Saved to %1": "Saved to %1"
}
+21 -2
View File
@@ -310,7 +310,26 @@
"Color generation": "Chỉnh màu",
"Select output device": "Chọn đầu ra",
"Select input device": "Chọn đầu vào",
"Save chat from %1": "Lưu cuộc trò chuyện vào %1",
"%1 • %2 tasks": "%1 • %2 việc cần làm",
"Online models disallowed\n\nControlled by `policies.ai` config option": "Model trực tuyến không được cho phép\n\nCài đặt bởi lựa chọn `policies.ai`"
"Online models disallowed\n\nControlled by `policies.ai` config option": "Model trực tuyến không được cho phép\n\nCài đặt bởi lựa chọn `policies.ai`",
"Download complete": "Đã tải xong",
"Code saved to file": "Code đã lưu vào file",
"Critically low battery": "Pin rất thấp",
"Scroll to change brightness": "Cuộn để thay đổi độ sáng",
"Cloudflare WARP": "Cloudflare WARP",
"Toggles bar on press": "Mở/đóng bar khi ấn",
"Saved to %1": "Đã lưu vào %1",
"Elements": "Nguyên tố",
"Save chat to %1": "Lưu chat vào %1",
"Connection failed. Please inspect manually with the <tt>warp-cli</tt> command": "Kết nối không thành công. Hãy xem lại với lệnh <tt>warp-cli</tt>",
"Weather Service": "Thời tiết",
"Registration failed. Please inspect manually with the <tt>warp-cli</tt> command": "Đăng ký không thành công. Hãy xem lại với lệnh <tt>warp-cli</tt>",
"Consider plugging in your device": "Hãy cắm nguồn thiết bị của bạn",
"Cloudflare WARP (1.1.1.1)": "Cloudflare WARP (1.1.1.1)",
"Cannot find a GPS service. Using the fallback method instead.": "Không tìm thấy dịch vụ GPS. Đang sử dụng phương pháp dự phòng.",
"Opens bar on press": "Mở bar khi ấn",
"Low battery": "Pin yếu",
"Scroll to change volume": "Cuộn để thay đổi âm lượng",
"Please charge!\nAutomatic suspend triggers at %1": "Hãy sạc pin!\nHệ thống sẽ tự động ngủ khi pin xuống %1",
"Closes bar on press": "Đóng bar khi ấn"
}