From 1e7c84a6c1dbe6698b13137971155c20782913d5 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 17 Jul 2025 13:56:50 +0700 Subject: [PATCH] translations: update `qsTr`s to Translation.tr and allow translation of notifications --- .config/quickshell/ii/modules/bar/Bar.qml | 10 ++--- .../ii/modules/cheatsheet/Cheatsheet.qml | 4 +- .../quickshell/ii/modules/common/Config.qml | 2 +- .../sidebarLeft/aiChat/MessageCodeBlock.qml | 6 ++- .../modules/sidebarLeft/anime/BooruImage.qml | 2 +- .../quickToggles/CloudflareWarp.qml | 14 +++++-- .config/quickshell/ii/services/Battery.qml | 19 +++++++-- .config/quickshell/ii/services/Weather.qml | 39 +++++++++---------- .config/quickshell/translations/en_US.json | 26 ++++++++++++- .config/quickshell/translations/vi_VN.json | 23 ++++++++++- 10 files changed, 104 insertions(+), 41 deletions(-) diff --git a/.config/quickshell/ii/modules/bar/Bar.qml b/.config/quickshell/ii/modules/bar/Bar.qml index 08383c10e..23948029d 100644 --- a/.config/quickshell/ii/modules/bar/Bar.qml +++ b/.config/quickshell/ii/modules/bar/Bar.qml @@ -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; diff --git a/.config/quickshell/ii/modules/cheatsheet/Cheatsheet.qml b/.config/quickshell/ii/modules/cheatsheet/Cheatsheet.qml index a0b22779c..bc6b67ac9 100644 --- a/.config/quickshell/ii/modules/cheatsheet/Cheatsheet.qml +++ b/.config/quickshell/ii/modules/cheatsheet/Cheatsheet.qml @@ -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 diff --git a/.config/quickshell/ii/modules/common/Config.qml b/.config/quickshell/ii/modules/common/Config.qml index 33ebc94c6..1e73cea51 100644 --- a/.config/quickshell/ii/modules/common/Config.qml +++ b/.config/quickshell/ii/modules/common/Config.qml @@ -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 { diff --git a/.config/quickshell/ii/modules/sidebarLeft/aiChat/MessageCodeBlock.qml b/.config/quickshell/ii/modules/sidebarLeft/aiChat/MessageCodeBlock.qml index 957958ef4..eac41af56 100644 --- a/.config/quickshell/ii/modules/sidebarLeft/aiChat/MessageCodeBlock.qml +++ b/.config/quickshell/ii/modules/sidebarLeft/aiChat/MessageCodeBlock.qml @@ -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() } diff --git a/.config/quickshell/ii/modules/sidebarLeft/anime/BooruImage.qml b/.config/quickshell/ii/modules/sidebarLeft/anime/BooruImage.qml index 9ead31167..e8b24d196 100644 --- a/.config/quickshell/ii/modules/sidebarLeft/anime/BooruImage.qml +++ b/.config/quickshell/ii/modules/sidebarLeft/anime/BooruImage.qml @@ -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'` ]) } } diff --git a/.config/quickshell/ii/modules/sidebarRight/quickToggles/CloudflareWarp.qml b/.config/quickshell/ii/modules/sidebarRight/quickToggles/CloudflareWarp.qml index cdaf84b76..d9cf0fa6a 100644 --- a/.config/quickshell/ii/modules/sidebarRight/quickToggles/CloudflareWarp.qml +++ b/.config/quickshell/ii/modules/sidebarRight/quickToggles/CloudflareWarp.qml @@ -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 warp-cli command", "-a", "Shell"]) + Quickshell.execDetached(["notify-send", + Translation.tr("Cloudflare WARP"), + Translation.tr("Connection failed. Please inspect manually with the warp-cli 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 warp-cli command", "-a", "Shell"]) + Quickshell.execDetached(["notify-send", + Translation.tr("Cloudflare WARP"), + Translation.tr("Registration failed. Please inspect manually with the warp-cli 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)") } } diff --git a/.config/quickshell/ii/services/Battery.qml b/.config/quickshell/ii/services/Battery.qml index 6a432f3a4..abe7700d4 100644 --- a/.config/quickshell/ii/services/Battery.qml +++ b/.config/quickshell/ii/services/Battery.qml @@ -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: { diff --git a/.config/quickshell/ii/services/Weather.qml b/.config/quickshell/ii/services/Weather.qml index eb1a00af4..a72e7e2ed 100644 --- a/.config/quickshell/ii/services/Weather.qml +++ b/.config/quickshell/ii/services/Weather.qml @@ -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."); } } diff --git a/.config/quickshell/translations/en_US.json b/.config/quickshell/translations/en_US.json index 9446fd01d..7141cdaa5 100644 --- a/.config/quickshell/translations/en_US.json +++ b/.config/quickshell/translations/en_US.json @@ -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 warp-cli command": "Connection failed. Please inspect manually with the warp-cli command", + "Select input device": "Select input device", + "Registration failed. Please inspect manually with the warp-cli command": "Registration failed. Please inspect manually with the warp-cli command", + "Consider plugging in your device": "Consider plugging in your device", + "Low battery": "Low battery", + "Saved to %1": "Saved to %1" } \ No newline at end of file diff --git a/.config/quickshell/translations/vi_VN.json b/.config/quickshell/translations/vi_VN.json index e46230028..9c2bc979d 100644 --- a/.config/quickshell/translations/vi_VN.json +++ b/.config/quickshell/translations/vi_VN.json @@ -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 warp-cli command": "Kết nối không thành công. Hãy xem lại với lệnh warp-cli", + "Weather Service": "Thời tiết", + "Registration failed. Please inspect manually with the warp-cli command": "Đăng ký không thành công. Hãy xem lại với lệnh warp-cli", + "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" } \ No newline at end of file