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
@@ -1,5 +1,6 @@
import "root:/modules/common"
import "root:/modules/common/widgets"
import "root:/services/"
import QtQuick
import QtQuick.Layouts
import Quickshell.Wayland
@@ -26,7 +27,7 @@ Item {
font.pixelSize: Appearance.font.pixelSize.smaller
color: Appearance.colors.colSubtext
elide: Text.ElideRight
text: root.activeWindow?.activated ? root.activeWindow?.appId : qsTr("Desktop")
text: root.activeWindow?.activated ? root.activeWindow?.appId : Translation.tr("Desktop")
}
StyledText {
@@ -34,7 +35,7 @@ Item {
font.pixelSize: Appearance.font.pixelSize.small
color: Appearance.colors.colOnLayer0
elide: Text.ElideRight
text: root.activeWindow?.activated ? root.activeWindow?.title : `${qsTr("Workspace")} ${monitor.activeWorkspace?.id}`
text: root.activeWindow?.activated ? root.activeWindow?.title : `${Translation.tr("Workspace")} ${monitor.activeWorkspace?.id}`
}
}
+2 -2
View File
@@ -131,7 +131,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
@@ -329,7 +329,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
+1 -1
View File
@@ -13,7 +13,7 @@ Item {
id: root
property bool borderless: ConfigOptions.bar.borderless
readonly property MprisPlayer activePlayer: MprisController.activePlayer
readonly property string cleanedTitle: StringUtils.cleanMusicTitle(activePlayer?.trackTitle) || qsTr("No media")
readonly property string cleanedTitle: StringUtils.cleanMusicTitle(activePlayer?.trackTitle) || Translation.tr("No media")
Layout.fillHeight: true
implicitWidth: rowLayout.implicitWidth + rowLayout.spacing * 2
@@ -110,7 +110,7 @@ Scope { // Scope
Layout.alignment: Qt.AlignHCenter
font.family: Appearance.font.family.title
font.pixelSize: Appearance.font.pixelSize.title
text: qsTr("Cheat sheet")
text: Translation.tr("Cheat sheet")
}
CheatsheetKeybinds {}
}
@@ -137,7 +137,7 @@ Scope { // Scope
GlobalShortcut {
name: "cheatsheetToggle"
description: qsTr("Toggles cheatsheet on press")
description: Translation.tr("Toggles cheatsheet on press")
onPressed: {
cheatsheetLoader.active = !cheatsheetLoader.active;
@@ -146,7 +146,7 @@ Scope { // Scope
GlobalShortcut {
name: "cheatsheetOpen"
description: qsTr("Opens cheatsheet on press")
description: Translation.tr("Opens cheatsheet on press")
onPressed: {
cheatsheetLoader.active = true;
@@ -155,7 +155,7 @@ Scope { // Scope
GlobalShortcut {
name: "cheatsheetClose"
description: qsTr("Closes cheatsheet on press")
description: Translation.tr("Closes cheatsheet on press")
onPressed: {
cheatsheetLoader.active = false;
@@ -91,6 +91,7 @@ Singleton {
}
property QtObject language: QtObject {
property string ui: "auto" // Interface language: "auto", "en", "zh-CN", "zh-TW", etc.
property QtObject translator: QtObject {
property string engine: "auto" // Run `trans -list-engines` for available engines. auto should use google
property string targetLanguage: "auto" // Run `trans -list-all` for available languages
@@ -97,7 +97,7 @@ Item { // Notification item area
onPressAndHold: (mouse) => {
if (mouse.button === Qt.LeftButton) {
Hyprland.dispatch(`exec wl-copy '${StringUtils.shellSingleQuoteEscape(notificationObject.body)}'`)
notificationSummaryText.text = String.format(qsTr("{0} (copied)"), notificationObject.summary)
notificationSummaryText.text = String.format(Translation.tr("{0} (copied)"), notificationObject.summary)
}
}
onDraggingChanged: () => {
@@ -257,7 +257,7 @@ Item { // Notification item area
NotificationActionButton {
Layout.fillWidth: true
buttonText: qsTr("Close")
buttonText: Translation.tr("Close")
urgency: notificationObject.urgency
implicitWidth: (notificationObject.actions.length == 0) ? ((actionsFlickable.width - actionRowLayout.spacing) / 2) :
(contentItem.implicitWidth + leftPadding + rightPadding)
@@ -1,4 +1,5 @@
import "root:/modules/common"
import "root:/services/"
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
@@ -7,7 +8,7 @@ import Quickshell
ColumnLayout {
id: root
spacing: 0
required property var tabButtonList // Something like [{"icon": "notifications", "name": qsTr("Notifications")}, {"icon": "volume_up", "name": qsTr("Volume mixer")}]
required property var tabButtonList // Something like [{"icon": "notifications", "name": Translation.tr("Notifications")}, {"icon": "volume_up", "name": Translation.tr("Volume mixer")}]
required property var externalTrackedTab
property bool enableIndicatorAnimation: false
property color colIndicator: Appearance?.colors.colPrimary ?? "#65558F"
@@ -1,6 +1,7 @@
import "root:/modules/common"
import "root:/modules/common/widgets"
import "root:/services"
import "root:/services/"
import Qt5Compat.GraphicalEffects
import QtQuick
import QtQuick.Controls
@@ -113,11 +114,11 @@ Item {
Layout.alignment: Qt.AlignRight
DialogButton {
buttonText: qsTr("Cancel")
buttonText: Translation.tr("Cancel")
onClicked: root.canceled()
}
DialogButton {
buttonText: qsTr("OK")
buttonText: Translation.tr("OK")
onClicked: root.selected(
root.selectedId === -1 ? null :
root.items[root.selectedId]
@@ -158,7 +158,7 @@ Scope {
GlobalShortcut {
name: "mediaControlsToggle"
description: qsTr("Toggles media controls on press")
description: Translation.tr("Toggles media controls on press")
onPressed: {
if (!mediaControlsLoader.active && Mpris.players.values.filter(player => isRealPlayer(player)).length === 0) {
@@ -170,7 +170,7 @@ Scope {
}
GlobalShortcut {
name: "mediaControlsOpen"
description: qsTr("Opens media controls on press")
description: Translation.tr("Opens media controls on press")
onPressed: {
mediaControlsLoader.active = true;
@@ -179,7 +179,7 @@ Scope {
}
GlobalShortcut {
name: "mediaControlsClose"
description: qsTr("Closes media controls on press")
description: Translation.tr("Closes media controls on press")
onPressed: {
mediaControlsLoader.active = false;
@@ -108,7 +108,7 @@ Scope {
icon: "light_mode"
rotateIcon: true
scaleIcon: true
name: qsTr("Brightness")
name: Translation.tr("Brightness")
}
}
}
@@ -134,7 +134,7 @@ Scope {
GlobalShortcut {
name: "osdBrightnessTrigger"
description: qsTr("Triggers brightness OSD on press")
description: Translation.tr("Triggers brightness OSD on press")
onPressed: {
root.triggerOsd()
@@ -142,7 +142,7 @@ Scope {
}
GlobalShortcut {
name: "osdBrightnessHide"
description: qsTr("Hides brightness OSD on press")
description: Translation.tr("Hides brightness OSD on press")
onPressed: {
root.showOsdValues = false
@@ -121,7 +121,7 @@ Scope {
Layout.fillWidth: true
value: Audio.sink?.audio.volume ?? 0
icon: Audio.sink?.audio.muted ? "volume_off" : "volume_up"
name: qsTr("Volume")
name: Translation.tr("Volume")
}
Item {
@@ -185,7 +185,7 @@ Scope {
}
GlobalShortcut {
name: "osdVolumeTrigger"
description: qsTr("Triggers volume OSD on press")
description: Translation.tr("Triggers volume OSD on press")
onPressed: {
root.triggerOsd()
@@ -193,7 +193,7 @@ Scope {
}
GlobalShortcut {
name: "osdVolumeHide"
description: qsTr("Hides volume OSD on press")
description: Translation.tr("Hides volume OSD on press")
onPressed: {
root.showOsdValues = false
@@ -141,7 +141,7 @@ Scope { // Scope
GlobalShortcut {
name: "oskToggle"
description: qsTr("Toggles on screen keyboard on press")
description: Translation.tr("Toggles on screen keyboard on press")
onPressed: {
oskLoader.active = !oskLoader.active;
@@ -150,7 +150,7 @@ Scope { // Scope
GlobalShortcut {
name: "oskOpen"
description: qsTr("Opens on screen keyboard on press")
description: Translation.tr("Opens on screen keyboard on press")
onPressed: {
oskLoader.active = true;
@@ -159,7 +159,7 @@ Scope { // Scope
GlobalShortcut {
name: "oskClose"
description: qsTr("Closes on screen keyboard on press")
description: Translation.tr("Closes on screen keyboard on press")
onPressed: {
oskLoader.active = false;
@@ -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
+12 -12
View File
@@ -70,7 +70,7 @@ Scope {
font.family: Appearance.font.family.title
font.pixelSize: Appearance.font.pixelSize.title
font.weight: Font.DemiBold
text: qsTr("Session")
text: Translation.tr("Session")
}
StyledText { // Small instruction
@@ -78,7 +78,7 @@ Scope {
horizontalAlignment: Text.AlignHCenter
font.family: Appearance.font.family.title
font.pixelSize: Appearance.font.pixelSize.normal
text: qsTr("Arrow keys to navigate, Enter to select\nEsc or click anywhere to cancel")
text: Translation.tr("Arrow keys to navigate, Enter to select\nEsc or click anywhere to cancel")
}
}
@@ -91,7 +91,7 @@ Scope {
id: sessionLock
focus: sessionRoot.visible
buttonIcon: "lock"
buttonText: qsTr("Lock")
buttonText: Translation.tr("Lock")
onClicked: { Hyprland.dispatch("exec loginctl lock-session"); sessionRoot.hide() }
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
KeyNavigation.right: sessionSleep
@@ -100,7 +100,7 @@ Scope {
SessionActionButton {
id: sessionSleep
buttonIcon: "dark_mode"
buttonText: qsTr("Sleep")
buttonText: Translation.tr("Sleep")
onClicked: { Hyprland.dispatch("exec systemctl suspend || loginctl suspend"); sessionRoot.hide() }
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
KeyNavigation.left: sessionLock
@@ -110,7 +110,7 @@ Scope {
SessionActionButton {
id: sessionLogout
buttonIcon: "logout"
buttonText: qsTr("Logout")
buttonText: Translation.tr("Logout")
onClicked: { Hyprland.dispatch("exec pkill Hyprland"); sessionRoot.hide() }
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
KeyNavigation.left: sessionSleep
@@ -120,7 +120,7 @@ Scope {
SessionActionButton {
id: sessionTaskManager
buttonIcon: "browse_activity"
buttonText: qsTr("Task Manager")
buttonText: Translation.tr("Task Manager")
onClicked: { Hyprland.dispatch(`exec ${ConfigOptions.apps.taskManager}`); sessionRoot.hide() }
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
KeyNavigation.left: sessionLogout
@@ -130,7 +130,7 @@ Scope {
SessionActionButton {
id: sessionHibernate
buttonIcon: "downloading"
buttonText: qsTr("Hibernate")
buttonText: Translation.tr("Hibernate")
onClicked: { Hyprland.dispatch("exec systemctl hibernate || loginctl hibernate"); sessionRoot.hide() }
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
KeyNavigation.up: sessionLock
@@ -139,7 +139,7 @@ Scope {
SessionActionButton {
id: sessionShutdown
buttonIcon: "power_settings_new"
buttonText: qsTr("Shutdown")
buttonText: Translation.tr("Shutdown")
onClicked: { Hyprland.dispatch("exec systemctl poweroff || loginctl poweroff"); sessionRoot.hide() }
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
KeyNavigation.left: sessionHibernate
@@ -149,7 +149,7 @@ Scope {
SessionActionButton {
id: sessionReboot
buttonIcon: "restart_alt"
buttonText: qsTr("Reboot")
buttonText: Translation.tr("Reboot")
onClicked: { Hyprland.dispatch("exec reboot || loginctl reboot"); sessionRoot.hide() }
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
KeyNavigation.left: sessionShutdown
@@ -159,7 +159,7 @@ Scope {
SessionActionButton {
id: sessionFirmwareReboot
buttonIcon: "settings_applications"
buttonText: qsTr("Reboot to firmware settings")
buttonText: Translation.tr("Reboot to firmware settings")
onClicked: { Hyprland.dispatch("exec systemctl reboot --firmware-setup || loginctl reboot --firmware-setup"); sessionRoot.hide() }
onFocusChanged: { if (focus) sessionRoot.subtitle = buttonText }
KeyNavigation.up: sessionTaskManager
@@ -209,7 +209,7 @@ Scope {
GlobalShortcut {
name: "sessionToggle"
description: qsTr("Toggles session screen on press")
description: Translation.tr("Toggles session screen on press")
onPressed: {
sessionLoader.active = !sessionLoader.active;
@@ -218,7 +218,7 @@ Scope {
GlobalShortcut {
name: "sessionOpen"
description: qsTr("Opens session screen on press")
description: Translation.tr("Opens session screen on press")
onPressed: {
sessionLoader.active = true;
@@ -44,21 +44,21 @@ Item {
property var allCommands: [
{
name: "model",
description: qsTr("Choose model"),
description: Translation.tr("Choose model"),
execute: (args) => {
Ai.setModel(args[0]);
}
},
{
name: "clear",
description: qsTr("Clear chat history"),
description: Translation.tr("Clear chat history"),
execute: () => {
Ai.clearMessages();
}
},
{
name: "key",
description: qsTr("Set API key"),
description: Translation.tr("Set API key"),
execute: (args) => {
if (args[0] == "get") {
Ai.printApiKey()
@@ -69,7 +69,7 @@ Item {
},
{
name: "temp",
description: qsTr("Set temperature (randomness) of the model. Values range between 0 to 2 for Gemini, 0 to 1 for other models. Default is 0.5."),
description: Translation.tr("Set temperature (randomness) of the model. Values range between 0 to 2 for Gemini, 0 to 1 for other models. Default is 0.5."),
execute: (args) => {
// console.log(args)
if (args.length == 0 || args[0] == "get") {
@@ -82,7 +82,7 @@ Item {
},
{
name: "test",
description: qsTr("Markdown test"),
description: Translation.tr("Markdown test"),
execute: () => {
Ai.addMessage(`
<think>
@@ -148,7 +148,7 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\)
if (commandObj) {
commandObj.execute(args);
} else {
Ai.addMessage(qsTr("Unknown command: ") + command, Ai.interfaceRole);
Ai.addMessage(Translation.tr("Unknown command: ") + command, Ai.interfaceRole);
}
}
else {
@@ -235,7 +235,7 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\)
font.family: Appearance.font.family.title
color: Appearance.m3colors.m3outline
horizontalAlignment: Text.AlignHCenter
text: qsTr("Large language models")
text: Translation.tr("Large language models")
}
StyledText {
id: widgetDescriptionText
@@ -244,7 +244,7 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\)
color: Appearance.m3colors.m3outline
horizontalAlignment: Text.AlignLeft
wrapMode: Text.Wrap
text: qsTr("Type /key to get started with online models\nCtrl+O to expand the sidebar\nCtrl+P to detach sidebar into a window")
text: Translation.tr("Type /key to get started with online models\nCtrl+O to expand the sidebar\nCtrl+P to detach sidebar into a window")
}
}
}
@@ -366,7 +366,7 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\)
Layout.fillWidth: true
padding: 10
color: activeFocus ? Appearance.m3colors.m3onSurface : Appearance.m3colors.m3onSurfaceVariant
placeholderText: StringUtils.format(qsTr('Message the model... "{0}" for commands'), root.commandPrefix)
placeholderText: StringUtils.format(Translation.tr('Message the model... "{0}" for commands'), root.commandPrefix)
background: null
@@ -510,7 +510,7 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\)
id: toolTip
extraVisibleCondition: false
alternativeVisibleCondition: mouseArea.containsMouse // Show tooltip when hovered
content: StringUtils.format(qsTr("Current model: {0}\nSet it with {1}model MODEL"),
content: StringUtils.format(Translation.tr("Current model: {0}\nSet it with {1}model MODEL"),
Ai.getModel().name, root.commandPrefix)
}
@@ -6,6 +6,7 @@ import "root:/modules/common/functions/fuzzysort.js" as Fuzzy
import "root:/modules/common/functions/string_utils.js" as StringUtils
import "root:/modules/common/functions/file_utils.js" as FileUtils
import "./anime/"
import "root:/services/"
import Qt.labs.platform
import QtQuick
import QtQuick.Controls
@@ -39,21 +40,21 @@ Item {
property var allCommands: [
{
name: "mode",
description: qsTr("Set the current API provider"),
description: Translation.tr("Set the current API provider"),
execute: (args) => {
Booru.setProvider(args[0]);
}
},
{
name: "clear",
description: qsTr("Clear the current list of images"),
description: Translation.tr("Clear the current list of images"),
execute: () => {
Booru.clearResponses();
}
},
{
name: "next",
description: qsTr("Get the next page of results"),
description: Translation.tr("Get the next page of results"),
execute: () => {
if (root.responses.length > 0) {
const lastResponse = root.responses[root.responses.length - 1];
@@ -63,14 +64,14 @@ Item {
},
{
name: "safe",
description: qsTr("Disable NSFW content"),
description: Translation.tr("Disable NSFW content"),
execute: () => {
PersistentStateManager.setState("booru.allowNsfw", false);
}
},
{
name: "lewd",
description: qsTr("Allow NSFW content"),
description: Translation.tr("Allow NSFW content"),
execute: () => {
PersistentStateManager.setState("booru.allowNsfw", true);
}
@@ -86,7 +87,7 @@ Item {
if (commandObj) {
commandObj.execute(args);
} else {
Booru.addSystemMessage(qsTr("Unknown command: ") + command);
Booru.addSystemMessage(Translation.tr("Unknown command: ") + command);
}
}
else if (inputText.trim() == "+") {
@@ -208,7 +209,7 @@ Item {
font.family: Appearance.font.family.title
color: Appearance.m3colors.m3outline
horizontalAlignment: Text.AlignHCenter
text: qsTr("Anime boorus")
text: Translation.tr("Anime boorus")
}
}
}
@@ -245,7 +246,7 @@ Item {
font.pixelSize: Appearance.font.pixelSize.smaller
color: Appearance.m3colors.m3inverseOnSurface
wrapMode: Text.Wrap
text: StringUtils.format(qsTr("{0} queries pending"), Booru.runningRequests)
text: StringUtils.format(Translation.tr("{0} queries pending"), Booru.runningRequests)
}
}
}
@@ -381,7 +382,7 @@ Item {
padding: 10
color: activeFocus ? Appearance.m3colors.m3onSurface : Appearance.m3colors.m3onSurfaceVariant
renderType: Text.NativeRendering
placeholderText: StringUtils.format(qsTr('Enter tags, or "{0}" for commands'), root.commandPrefix)
placeholderText: StringUtils.format(Translation.tr('Enter tags, or "{0}" for commands'), root.commandPrefix)
background: null
@@ -544,8 +545,8 @@ Item {
id: toolTip
extraVisibleCondition: false
alternativeVisibleCondition: mouseArea.containsMouse // Show tooltip when hovered
// content: qsTr("The current API used. Endpoint: ") + Booru.providers[Booru.currentProvider].url + qsTr("\nSet with /mode PROVIDER")
content: StringUtils.format(qsTr("Current API endpoint: {0}\nSet it with {1}mode PROVIDER"),
// content: Translation.tr("The current API used. Endpoint: ") + Booru.providers[Booru.currentProvider].url + Translation.tr("\nSet with /mode PROVIDER")
content: StringUtils.format(Translation.tr("Current API endpoint: {0}\nSet it with {1}mode PROVIDER"),
Booru.providers[Booru.currentProvider].url, root.commandPrefix)
}
@@ -586,7 +587,7 @@ Item {
Layout.alignment: Qt.AlignVCenter
font.pixelSize: Appearance.font.pixelSize.smaller
color: nsfwSwitch.enabled ? Appearance.colors.colOnLayer1 : Appearance.m3colors.m3outline
text: qsTr("Allow NSFW")
text: Translation.tr("Allow NSFW")
}
StyledSwitch {
id: nsfwSwitch
@@ -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
@@ -168,7 +169,7 @@ Scope { // Scope
GlobalShortcut {
name: "sidebarLeftToggle"
description: qsTr("Toggles left sidebar on press")
description: Translation.tr("Toggles left sidebar on press")
onPressed: {
GlobalStates.sidebarLeftOpen = !GlobalStates.sidebarLeftOpen;
@@ -177,7 +178,7 @@ Scope { // Scope
GlobalShortcut {
name: "sidebarLeftOpen"
description: qsTr("Opens left sidebar on press")
description: Translation.tr("Opens left sidebar on press")
onPressed: {
GlobalStates.sidebarLeftOpen = true;
@@ -186,7 +187,7 @@ Scope { // Scope
GlobalShortcut {
name: "sidebarLeftClose"
description: qsTr("Closes left sidebar on press")
description: Translation.tr("Closes left sidebar on press")
onPressed: {
GlobalStates.sidebarLeftOpen = false;
@@ -195,7 +196,7 @@ Scope { // Scope
GlobalShortcut {
name: "sidebarLeftToggleDetach"
description: qsTr("Detach left sidebar into a window/Attach it back")
description: Translation.tr("Detach left sidebar into a window/Attach it back")
onPressed: {
root.detach = !root.detach;
@@ -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
@@ -18,9 +19,9 @@ Item {
required property var scopeRoot
anchors.fill: parent
property var tabButtonList: [
...(ConfigOptions.policies.ai !== 0 ? [{"icon": "neurology", "name": qsTr("Intelligence")}] : []),
{"icon": "translate", "name": qsTr("Translator")},
...(ConfigOptions.policies.weeb === 1 ? [{"icon": "bookmark_heart", "name": qsTr("Anime")}] : [])
...(ConfigOptions.policies.ai !== 0 ? [{"icon": "neurology", "name": Translation.tr("Intelligence")}] : []),
{"icon": "translate", "name": Translation.tr("Translator")},
...(ConfigOptions.policies.weeb === 1 ? [{"icon": "bookmark_heart", "name": Translation.tr("Anime")}] : [])
]
property int selectedTab: 0
@@ -123,7 +123,7 @@ Item {
TextCanvas { // Content translation
id: outputCanvas
isInput: false
placeholderText: qsTr("Translation goes here...")
placeholderText: Translation.tr("Translation goes here...")
property bool hasTranslation: (root.translatedText.trim().length > 0)
text: hasTranslation ? root.translatedText : ""
GroupButton {
@@ -178,7 +178,7 @@ Item {
TextCanvas { // Content input
id: inputCanvas
isInput: true
placeholderText: qsTr("Enter text to translate...")
placeholderText: Translation.tr("Enter text to translate...")
onInputTextChanged: {
translateTimer.restart();
}
@@ -223,7 +223,7 @@ Item {
z: 9999
sourceComponent: SelectionDialog {
id: languageSelectorDialog
titleText: qsTr("Select Language")
titleText: Translation.tr("Select Language")
items: root.languages
defaultChoice: root.languageSelectorTarget ? root.targetLanguage : root.sourceLanguage
onCanceled: () => {
@@ -151,7 +151,7 @@ Rectangle {
color: Appearance.m3colors.m3onSecondaryContainer
text: messageData?.role == 'assistant' ? Ai.models[messageData?.model].name :
(messageData?.role == 'user' && SystemInfo.username) ? SystemInfo.username :
qsTr("Interface")
Translation.tr("Interface")
}
}
}
@@ -173,7 +173,7 @@ Rectangle {
text: "visibility_off"
}
StyledToolTip {
content: qsTr("Not visible to model")
content: Translation.tr("Not visible to model")
}
}
@@ -200,7 +200,7 @@ Rectangle {
}
StyledToolTip {
content: qsTr("Copy")
content: Translation.tr("Copy")
}
}
AiMessageControlButton {
@@ -215,7 +215,7 @@ Rectangle {
}
}
StyledToolTip {
content: root.editing ? qsTr("Save") : qsTr("Edit")
content: root.editing ? Translation.tr("Save") : Translation.tr("Edit")
}
}
AiMessageControlButton {
@@ -226,7 +226,7 @@ Rectangle {
root.renderMarkdown = !root.renderMarkdown
}
StyledToolTip {
content: qsTr("View Markdown source")
content: Translation.tr("View Markdown source")
}
}
AiMessageControlButton {
@@ -236,7 +236,7 @@ Rectangle {
Ai.removeMessage(root.messageIndex)
}
StyledToolTip {
content: qsTr("Delete")
content: Translation.tr("Delete")
}
}
}
@@ -87,7 +87,7 @@ ColumnLayout {
}
}
StyledToolTip {
content: qsTr("Copy code")
content: Translation.tr("Copy code")
}
}
AiMessageControlButton {
@@ -111,7 +111,7 @@ ColumnLayout {
}
}
StyledToolTip {
content: qsTr("Save to Downloads")
content: Translation.tr("Save to Downloads")
}
}
}
@@ -124,7 +124,7 @@ ColumnLayout {
wrapMode: TextEdit.Wrap
color: messageData.thinking ? Appearance.colors.colSubtext : Appearance.colors.colOnLayer1
textFormat: renderMarkdown ? TextEdit.MarkdownText : TextEdit.PlainText
text: qsTr("Waiting for response...")
text: Translation.tr("Waiting for response...")
onTextChanged: {
if (!root.editing) return
@@ -99,7 +99,7 @@ Item {
id: thinkBlockLanguage
Layout.fillWidth: false
Layout.alignment: Qt.AlignLeft
text: root.completed ? qsTr("Chain of Thought") : (qsTr("Thinking") + ".".repeat(Math.random() * 4))
text: root.completed ? Translation.tr("Chain of Thought") : (Translation.tr("Thinking") + ".".repeat(Math.random() * 4))
}
Item { Layout.fillWidth: true }
RippleButton { // Expand button
@@ -153,7 +153,7 @@ Button {
MenuButton {
id: openFileLinkButton
Layout.fillWidth: true
buttonText: qsTr("Open file link")
buttonText: Translation.tr("Open file link")
onClicked: {
root.showActions = false
Hyprland.dispatch("keyword cursor:no_warps true")
@@ -165,7 +165,7 @@ Button {
id: sourceButton
visible: root.imageData.source && root.imageData.source.length > 0
Layout.fillWidth: true
buttonText: StringUtils.format(qsTr("Go to source ({0})"), StringUtils.getDomain(root.imageData.source))
buttonText: StringUtils.format(Translation.tr("Go to source ({0})"), StringUtils.getDomain(root.imageData.source))
enabled: root.imageData.source && root.imageData.source.length > 0
onClicked: {
root.showActions = false
@@ -177,10 +177,10 @@ Button {
MenuButton {
id: downloadButton
Layout.fillWidth: true
buttonText: qsTr("Download")
buttonText: Translation.tr("Download")
onClicked: {
root.showActions = false
Hyprland.dispatch(`exec 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'`)
Hyprland.dispatch(`exec 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'`)
}
}
}
@@ -4,6 +4,7 @@ import "root:/modules/common"
import "root:/modules/common/widgets"
import "root:/modules/common/functions/string_utils.js" as StringUtils
import "../"
import "root:/services/"
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
@@ -94,7 +95,7 @@ Rectangle {
font.pixelSize: Appearance.font.pixelSize.smaller
color: Appearance.colors.colOnLayer2
// text: `Page ${root.responseData.page}`
text: StringUtils.format(qsTr("Page {0}"), root.responseData.page)
text: StringUtils.format(Translation.tr("Page {0}"), root.responseData.page)
}
}
}
@@ -78,7 +78,7 @@ Rectangle {
visible: root.isInput
Layout.leftMargin: 10
sourceComponent: Text {
text: qsTr("%1 characters").arg(inputLoader.item.text.length)
text: Translation.tr("%1 characters").arg(inputLoader.item.text.length)
color: Appearance.colors.colOnLayer1
font.pixelSize: Appearance.font.pixelSize.smaller
}
@@ -5,6 +5,7 @@ import "./calendar"
import "./notifications"
import "./todo"
import "./volumeMixer"
import "root:/services/"
import Qt5Compat.GraphicalEffects
import QtQuick
import QtQuick.Controls
@@ -17,7 +18,7 @@ Rectangle {
color: Appearance.colors.colLayer1
property int selectedTab: 0
property var tabButtonList: [{"icon": "notifications", "name": qsTr("Notifications")}, {"icon": "volume_up", "name": qsTr("Volume mixer")}]
property var tabButtonList: [{"icon": "notifications", "name": Translation.tr("Notifications")}, {"icon": "volume_up", "name": Translation.tr("Volume mixer")}]
Keys.onPressed: (event) => {
if (event.key === Qt.Key_PageDown || event.key === Qt.Key_PageUp) {
@@ -4,6 +4,7 @@ import "root:/modules/common"
import "root:/modules/common/widgets"
import "root:/modules/common/functions/string_utils.js" as StringUtils
import "./quickToggles/"
import "root:/services/"
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
@@ -119,7 +120,7 @@ Scope {
StyledText {
font.pixelSize: Appearance.font.pixelSize.normal
color: Appearance.colors.colOnLayer0
text: StringUtils.format(qsTr("Uptime: {0}"), DateTime.uptime)
text: StringUtils.format(Translation.tr("Uptime: {0}"), DateTime.uptime)
textFormat: Text.MarkdownText
}
@@ -136,7 +137,7 @@ Scope {
Quickshell.reload(true)
}
StyledToolTip {
content: qsTr("Reload Hyprland & Quickshell")
content: Translation.tr("Reload Hyprland & Quickshell")
}
}
QuickToggleButton {
@@ -147,7 +148,7 @@ Scope {
Hyprland.dispatch(`global quickshell:sidebarRightClose`)
}
StyledToolTip {
content: qsTr("Plasma Settings")
content: Translation.tr("Plasma Settings")
}
}
QuickToggleButton {
@@ -157,7 +158,7 @@ Scope {
Hyprland.dispatch("global quickshell:sessionOpen")
}
StyledToolTip {
content: qsTr("Session")
content: Translation.tr("Session")
}
}
}
@@ -218,7 +219,7 @@ Scope {
GlobalShortcut {
name: "sidebarRightToggle"
description: qsTr("Toggles right sidebar on press")
description: Translation.tr("Toggles right sidebar on press")
onPressed: {
GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen;
@@ -227,7 +228,7 @@ Scope {
}
GlobalShortcut {
name: "sidebarRightOpen"
description: qsTr("Opens right sidebar on press")
description: Translation.tr("Opens right sidebar on press")
onPressed: {
GlobalStates.sidebarRightOpen = true;
@@ -236,7 +237,7 @@ Scope {
}
GlobalShortcut {
name: "sidebarRightClose"
description: qsTr("Closes right sidebar on press")
description: Translation.tr("Closes right sidebar on press")
onPressed: {
GlobalStates.sidebarRightOpen = false;
@@ -48,7 +48,7 @@ Item {
CalendarHeaderButton {
clip: true
buttonText: `${monthShift != 0 ? "• " : ""}${viewingDate.toLocaleDateString(Qt.locale(), "MMMM yyyy")}`
tooltipText: (monthShift === 0) ? "" : qsTr("Jump to current month")
tooltipText: (monthShift === 0) ? "" : Translation.tr("Jump to current month")
onClicked: {
monthShift = 0;
}
@@ -1,6 +1,7 @@
import "root:/modules/common"
import "root:/modules/common/widgets"
import "root:/services"
import "root:/services/"
import Qt5Compat.GraphicalEffects
import QtQuick
import QtQuick.Controls
@@ -61,7 +62,7 @@ Item {
font.pixelSize: Appearance.font.pixelSize.normal
color: Appearance.m3colors.m3outline
horizontalAlignment: Text.AlignHCenter
text: qsTr("No notifications")
text: Translation.tr("No notifications")
}
}
}
@@ -101,7 +102,7 @@ Item {
NotificationStatusButton {
buttonIcon: "notifications_paused"
buttonText: qsTr("Silent")
buttonText: Translation.tr("Silent")
toggled: Notifications.silent
onClicked: () => {
Notifications.silent = !Notifications.silent;
@@ -109,7 +110,7 @@ Item {
}
NotificationStatusButton {
buttonIcon: "clear_all"
buttonText: qsTr("Clear")
buttonText: Translation.tr("Clear")
onClicked: () => {
Notifications.discardAllNotifications()
}
@@ -28,9 +28,9 @@ QuickToggleButton {
}
}
StyledToolTip {
content: StringUtils.format(qsTr("{0} | Right-click to configure"),
content: StringUtils.format(Translation.tr("{0} | Right-click to configure"),
(Bluetooth.bluetoothEnabled && Bluetooth.bluetoothDeviceName.length > 0) ?
Bluetooth.bluetoothDeviceName : qsTr("Bluetooth"))
Bluetooth.bluetoothDeviceName : Translation.tr("Bluetooth"))
}
}
@@ -1,6 +1,7 @@
import "root:/modules/common"
import "root:/modules/common/widgets"
import "../"
import "root:/services/"
import Quickshell
import Quickshell.Io
import Quickshell.Hyprland
@@ -21,6 +22,6 @@ QuickToggleButton {
}
StyledToolTip {
content: qsTr("Game mode")
content: Translation.tr("Game mode")
}
}
@@ -1,6 +1,7 @@
import "root:/modules/common"
import "root:/modules/common/widgets"
import "../"
import "root:/services/"
import Quickshell.Io
import Quickshell
import Quickshell.Hyprland
@@ -27,6 +28,6 @@ QuickToggleButton {
}
}
StyledToolTip {
content: qsTr("Keep system awake")
content: Translation.tr("Keep system awake")
}
}
@@ -3,6 +3,7 @@ import "root:/modules/common"
import "root:/modules/common/widgets"
import "root:/modules/common/functions/string_utils.js" as StringUtils
import "../"
import "root:/services/"
import QtQuick
import Quickshell
import Quickshell.Io
@@ -28,6 +29,6 @@ QuickToggleButton {
}
}
StyledToolTip {
content: StringUtils.format(qsTr("{0} | Right-click to configure"), Network.networkName)
content: StringUtils.format(Translation.tr("{0} | Right-click to configure"), Network.networkName)
}
}
@@ -1,6 +1,7 @@
import "root:/modules/common"
import "root:/modules/common/widgets"
import "../"
import "root:/services/"
import Quickshell.Io
import Quickshell
@@ -37,6 +38,6 @@ QuickToggleButton {
}
}
StyledToolTip {
content: qsTr("Night Light")
content: Translation.tr("Night Light")
}
}
@@ -10,7 +10,7 @@ import QtQuick.Layouts
Item {
id: root
property int currentTab: 0
property var tabButtonList: [{"icon": "checklist", "name": qsTr("Unfinished")}, {"name": qsTr("Done"), "icon": "check_circle"}]
property var tabButtonList: [{"icon": "checklist", "name": Translation.tr("Unfinished")}, {"name": Translation.tr("Done"), "icon": "check_circle"}]
property bool showAddDialog: false
property int dialogMargins: 20
property int fabSize: 48
@@ -134,7 +134,7 @@ Item {
TaskList {
listBottomPadding: root.fabSize + root.fabMargins * 2
emptyPlaceholderIcon: "check_circle"
emptyPlaceholderText: qsTr("Nothing here!")
emptyPlaceholderText: Translation.tr("Nothing here!")
taskList: Todo.list
.map(function(item, i) { return Object.assign({}, item, {originalIndex: i}); })
.filter(function(item) { return !item.done; })
@@ -142,7 +142,7 @@ Item {
TaskList {
listBottomPadding: root.fabSize + root.fabMargins * 2
emptyPlaceholderIcon: "checklist"
emptyPlaceholderText: qsTr("Finished tasks will go here")
emptyPlaceholderText: Translation.tr("Finished tasks will go here")
taskList: Todo.list
.map(function(item, i) { return Object.assign({}, item, {originalIndex: i}); })
.filter(function(item) { return item.done; })
@@ -252,7 +252,7 @@ Item {
Layout.alignment: Qt.AlignLeft
color: Appearance.m3colors.m3onSurface
font.pixelSize: Appearance.font.pixelSize.larger
text: qsTr("Add task")
text: Translation.tr("Add task")
}
TextField {
@@ -265,7 +265,7 @@ Item {
renderType: Text.NativeRendering
selectedTextColor: Appearance.m3colors.m3onSecondaryContainer
selectionColor: Appearance.colors.colSecondaryContainer
placeholderText: qsTr("Task description")
placeholderText: Translation.tr("Task description")
placeholderTextColor: Appearance.m3colors.m3outline
focus: root.showAddDialog
onAccepted: dialog.addTask()
@@ -293,11 +293,11 @@ Item {
spacing: 5
DialogButton {
buttonText: qsTr("Cancel")
buttonText: Translation.tr("Cancel")
onClicked: root.showAddDialog = false
}
DialogButton {
buttonText: qsTr("Add")
buttonText: Translation.tr("Add")
enabled: todoInput.text.length > 0
onClicked: dialog.addTask()
}
@@ -1,6 +1,7 @@
import "root:/modules/common"
import "root:/modules/common/widgets"
import "root:/services"
import "root:/services/"
import Qt5Compat.GraphicalEffects
import QtQuick
import QtQuick.Controls
@@ -40,14 +41,14 @@ GroupButton {
Layout.fillWidth: true
elide: Text.ElideRight
font.pixelSize: Appearance.font.pixelSize.normal
text: input ? qsTr("Input") : qsTr("Output")
text: input ? Translation.tr("Input") : Translation.tr("Output")
color: Appearance.colors.colOnLayer2
}
StyledText {
Layout.fillWidth: true
elide: Text.ElideRight
font.pixelSize: Appearance.font.pixelSize.smaller
text: (input ? Pipewire.defaultAudioSource?.description : Pipewire.defaultAudioSink?.description) ?? qsTr("Unknown")
text: (input ? Pipewire.defaultAudioSource?.description : Pipewire.defaultAudioSink?.description) ?? Translation.tr("Unknown")
color: Appearance.m3colors.m3outline
}
}
@@ -1,6 +1,7 @@
import "root:/modules/common"
import "root:/modules/common/widgets"
import "root:/services"
import "root:/services/"
import Qt5Compat.GraphicalEffects
import QtQuick
import QtQuick.Controls
@@ -108,7 +109,7 @@ Item {
font.pixelSize: Appearance.font.pixelSize.normal
color: Appearance.m3colors.m3outline
horizontalAlignment: Text.AlignHCenter
text: qsTr("No audio source")
text: Translation.tr("No audio source")
}
}
}
@@ -262,13 +263,13 @@ Item {
Layout.alignment: Qt.AlignRight
DialogButton {
buttonText: qsTr("Cancel")
buttonText: Translation.tr("Cancel")
onClicked: {
root.showDeviceSelector = false
}
}
DialogButton {
buttonText: qsTr("OK")
buttonText: Translation.tr("OK")
onClicked: {
root.showDeviceSelector = false
if (root.selectedDevice) {