Quickshell qstr seems not to be working, trying to implement custom translation

Add Chinese (zh_CN) translations for Quickshell interface and settings
This commit is contained in:
月月
2025-06-17 12:29:21 +08:00
parent 54dfad1d5b
commit b32734b9f5
50 changed files with 1324 additions and 187 deletions
@@ -2,6 +2,7 @@ import "root:/"
import "root:/services"
import "root:/modules/common"
import "root:/modules/common/widgets"
import "root:/services/"
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
@@ -151,7 +152,7 @@ Scope {
GlobalShortcut {
name: "overviewToggle"
description: qsTr("Toggles overview on press")
description: Translation.tr("Toggles overview on press")
onPressed: {
GlobalStates.overviewOpen = !GlobalStates.overviewOpen
@@ -159,7 +160,7 @@ Scope {
}
GlobalShortcut {
name: "overviewClose"
description: qsTr("Closes overview")
description: Translation.tr("Closes overview")
onPressed: {
GlobalStates.overviewOpen = false
@@ -167,7 +168,7 @@ Scope {
}
GlobalShortcut {
name: "overviewToggleRelease"
description: qsTr("Toggles overview on release")
description: Translation.tr("Toggles overview on release")
onPressed: {
GlobalStates.superReleaseMightTrigger = true
@@ -183,9 +184,9 @@ Scope {
}
GlobalShortcut {
name: "overviewToggleReleaseInterrupt"
description: qsTr("Interrupts possibility of overview being toggled on release. ") +
qsTr("This is necessary because GlobalShortcut.onReleased in quickshell triggers whether or not you press something else while holding the key. ") +
qsTr("To make sure this works consistently, use binditn = MODKEYS, catchall in an automatically triggered submap that includes everything.")
description: Translation.tr("Interrupts possibility of overview being toggled on release. ") +
Translation.tr("This is necessary because GlobalShortcut.onReleased in quickshell triggers whether or not you press something else while holding the key. ") +
Translation.tr("To make sure this works consistently, use binditn = MODKEYS, catchall in an automatically triggered submap that includes everything.")
onPressed: {
GlobalStates.superReleaseMightTrigger = false
@@ -193,7 +194,7 @@ Scope {
}
GlobalShortcut {
name: "overviewClipboardToggle"
description: qsTr("Toggle clipboard query on overview widget")
description: Translation.tr("Toggle clipboard query on overview widget")
onPressed: {
if (GlobalStates.overviewOpen && overviewScope.dontAutoCancelSearch) {
@@ -216,7 +217,7 @@ Scope {
GlobalShortcut {
name: "overviewEmojiToggle"
description: qsTr("Toggle emoji query on overview widget")
description: Translation.tr("Toggle emoji query on overview widget")
onPressed: {
if (GlobalStates.overviewOpen && overviewScope.dontAutoCancelSearch) {
@@ -162,7 +162,7 @@ RippleButton {
StyledText {
font.pixelSize: Appearance.font.pixelSize.smaller
color: Appearance.colors.colSubtext
visible: root.itemType && root.itemType != qsTr("App")
visible: root.itemType && root.itemType != Translation.tr("App")
text: root.itemType
}
RowLayout {
@@ -220,7 +220,7 @@ Item { // Wrapper
color: activeFocus ? Appearance.m3colors.m3onSurface : Appearance.m3colors.m3onSurfaceVariant
selectedTextColor: Appearance.m3colors.m3onSecondaryContainer
selectionColor: Appearance.colors.colSecondaryContainer
placeholderText: qsTr("Search, calculate or run")
placeholderText: Translation.tr("Search, calculate or run")
placeholderTextColor: Appearance.m3colors.m3outline
implicitWidth: root.searchingText == "" ? Appearance.sizes.searchWidthCollapsed : Appearance.sizes.searchWidth
@@ -329,8 +329,8 @@ Item { // Wrapper
nonAppResultsTimer.restart();
const mathResultObject = {
name: root.mathResult,
clickActionName: qsTr("Copy"),
type: qsTr("Math result"),
clickActionName: Translation.tr("Copy"),
type: Translation.tr("Math result"),
fontType: "monospace",
materialSymbol: 'calculate',
execute: () => {
@@ -339,8 +339,8 @@ Item { // Wrapper
}
const commandResultObject = {
name: searchingText.replace("file://", ""),
clickActionName: qsTr("Run"),
type: qsTr("Run command"),
clickActionName: Translation.tr("Run"),
type: Translation.tr("Run command"),
fontType: "monospace",
materialSymbol: 'terminal',
execute: () => {
@@ -353,8 +353,8 @@ Item { // Wrapper
if (actionString.startsWith(root.searchingText) || root.searchingText.startsWith(actionString)) {
return {
name: root.searchingText.startsWith(actionString) ? root.searchingText : actionString,
clickActionName: qsTr("Run"),
type: qsTr("Action"),
clickActionName: Translation.tr("Run"),
type: Translation.tr("Action"),
materialSymbol: 'settings_suggest',
execute: () => {
action.execute(root.searchingText.split(" ").slice(1).join(" "))
@@ -371,8 +371,8 @@ Item { // Wrapper
result = result.concat(
AppSearch.fuzzyQuery(root.searchingText)
.map((entry) => {
entry.clickActionName = qsTr("Launch");
entry.type = qsTr("App");
entry.clickActionName = Translation.tr("Launch");
entry.type = Translation.tr("App");
return entry;
})
);
@@ -393,8 +393,8 @@ Item { // Wrapper
///////////////// Web search ////////////////
result.push({
name: root.searchingText,
clickActionName: qsTr("Search"),
type: qsTr("Search the web"),
clickActionName: Translation.tr("Search"),
type: Translation.tr("Search the web"),
materialSymbol: 'travel_explore',
execute: () => {
let url = ConfigOptions.search.engineBaseUrl + root.searchingText