forked from Shinonome/dots-hyprland
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user