1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 05:25:41 -05:00

i18n: don't load en json - move animated terms to properties

This commit is contained in:
bbedward
2025-10-08 20:31:41 -04:00
parent 9f3685e4d5
commit 3fb5d5c4f3
5 changed files with 33 additions and 32 deletions

View File

@@ -11,33 +11,24 @@ Singleton {
property var translations: ({})
property bool translationsLoaded: false
Component.onCompleted: {
translationLoader.running = true
}
Process {
FileView {
id: translationLoader
command: ["cat", Qt.resolvedUrl(`../translations/${currentLocale}.json`).toString().replace("file://", "")]
running: false
path: root.currentLocale === "en" ? "" : Qt.resolvedUrl(`../translations/${root.currentLocale}.json`)
stdout: StdioCollector {
onStreamFinished: () => {
try {
root.translations = JSON.parse(data)
root.translationsLoaded = true
console.log(`I18n: Loaded translations for locale '${currentLocale}' (${Object.keys(root.translations).length} contexts)`)
} catch (e) {
console.warn(`I18n: Error parsing translations for locale '${currentLocale}':`, e, "- falling back to English")
root.translationsLoaded = false
}
onLoaded: {
try {
root.translations = JSON.parse(text())
root.translationsLoaded = true
console.log(`I18n: Loaded translations for locale '${root.currentLocale}' (${Object.keys(root.translations).length} contexts)`)
} catch (e) {
console.warn(`I18n: Error parsing translations for locale '${root.currentLocale}':`, e, "- falling back to English")
root.translationsLoaded = false
}
}
onExited: (code, status) => {
if (code !== 0) {
console.warn(`I18n: Failed to load translations for locale '${currentLocale}' (exit code ${code}), falling back to English`)
root.translationsLoaded = false
}
onLoadFailed: (error) => {
console.warn(`I18n: Failed to load translations for locale '${root.currentLocale}' (${error}), falling back to English`)
root.translationsLoaded = false
}
}

View File

@@ -6,6 +6,8 @@ import qs.Modals.Clipboard
Rectangle {
id: keyboardHints
readonly property string hintsText: I18n.tr("Shift+Del: Clear All • Esc: Close")
height: ClipboardConstants.keyboardHintsHeight
radius: Theme.cornerRadius
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.95)
@@ -26,7 +28,7 @@ Rectangle {
}
StyledText {
text: I18n.tr("Shift+Del: Clear All • Esc: Close")
text: keyboardHints.hintsText
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
anchors.horizontalCenter: parent.horizontalCenter

View File

@@ -10,6 +10,12 @@ import qs.Widgets
PanelWindow {
id: root
readonly property string powerOptionsText: I18n.tr("Power Options")
readonly property string logOutText: I18n.tr("Log Out")
readonly property string suspendText: I18n.tr("Suspend")
readonly property string rebootText: I18n.tr("Reboot")
readonly property string powerOffText: I18n.tr("Power Off")
property bool powerMenuVisible: false
signal powerActionRequested(string action, string title, string message)
@@ -65,7 +71,7 @@ PanelWindow {
width: parent.width
StyledText {
text: I18n.tr("Power Options")
text: root.powerOptionsText
font.pixelSize: Theme.fontSizeLarge
color: Theme.surfaceText
font.weight: Font.Medium
@@ -118,7 +124,7 @@ PanelWindow {
}
StyledText {
text: I18n.tr("Log Out")
text: root.logOutText
font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceText
font.weight: Font.Medium
@@ -168,7 +174,7 @@ PanelWindow {
}
StyledText {
text: I18n.tr("Suspend")
text: root.suspendText
font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceText
font.weight: Font.Medium
@@ -218,7 +224,7 @@ PanelWindow {
}
StyledText {
text: I18n.tr("Reboot")
text: root.rebootText
font.pixelSize: Theme.fontSizeMedium
color: rebootArea.containsMouse ? Theme.warning : Theme.surfaceText
font.weight: Font.Medium
@@ -268,7 +274,7 @@ PanelWindow {
}
StyledText {
text: I18n.tr("Power Off")
text: root.powerOffText
font.pixelSize: Theme.fontSizeMedium
color: powerOffArea.containsMouse ? Theme.error : Theme.surfaceText
font.weight: Font.Medium

View File

@@ -21,6 +21,7 @@ PanelWindow {
property bool exiting: false
property bool _isDestroying: false
property bool _finalized: false
readonly property string clearText: I18n.tr("Clear")
signal entered
signal exitFinished
@@ -476,16 +477,16 @@ PanelWindow {
anchors.rightMargin: 16
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
width: Math.max(clearText.implicitWidth + 12, 50)
width: Math.max(clearTextLabel.implicitWidth + 12, 50)
height: 24
radius: 4
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
z: 20
StyledText {
id: clearText
id: clearTextLabel
text: I18n.tr("Clear")
text: win.clearText
color: clearButton.isHovered ? Theme.primary : Theme.surfaceVariantText
font.pixelSize: Theme.fontSizeSmall
font.weight: Font.Medium

View File

@@ -14,6 +14,7 @@ PanelWindow {
property var modelData
property bool shouldBeVisible: false
property real frozenWidth: 0
readonly property string copiedText: I18n.tr("Copied!")
Connections {
target: ToastService
@@ -280,7 +281,7 @@ PanelWindow {
StyledText {
id: tooltipLabel
anchors.centerIn: parent
text: I18n.tr("Copied!")
text: root.copiedText
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
}