1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-07 22:15:38 -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 var translations: ({})
property bool translationsLoaded: false property bool translationsLoaded: false
Component.onCompleted: { FileView {
translationLoader.running = true
}
Process {
id: translationLoader id: translationLoader
command: ["cat", Qt.resolvedUrl(`../translations/${currentLocale}.json`).toString().replace("file://", "")] path: root.currentLocale === "en" ? "" : Qt.resolvedUrl(`../translations/${root.currentLocale}.json`)
running: false
stdout: StdioCollector { onLoaded: {
onStreamFinished: () => { try {
try { root.translations = JSON.parse(text())
root.translations = JSON.parse(data) root.translationsLoaded = true
root.translationsLoaded = true console.log(`I18n: Loaded translations for locale '${root.currentLocale}' (${Object.keys(root.translations).length} contexts)`)
console.log(`I18n: Loaded translations for locale '${currentLocale}' (${Object.keys(root.translations).length} contexts)`) } catch (e) {
} catch (e) { console.warn(`I18n: Error parsing translations for locale '${root.currentLocale}':`, e, "- falling back to English")
console.warn(`I18n: Error parsing translations for locale '${currentLocale}':`, e, "- falling back to English") root.translationsLoaded = false
root.translationsLoaded = false
}
} }
} }
onExited: (code, status) => { onLoadFailed: (error) => {
if (code !== 0) { console.warn(`I18n: Failed to load translations for locale '${root.currentLocale}' (${error}), falling back to English`)
console.warn(`I18n: Failed to load translations for locale '${currentLocale}' (exit code ${code}), falling back to English`) root.translationsLoaded = false
root.translationsLoaded = false
}
} }
} }

View File

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

View File

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

View File

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

View File

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