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)")
}
}