Locale: fixed all Qt.locale calls to respect the user selected locale.

This commit is contained in:
ItsLemmy
2025-10-30 17:20:54 -04:00
parent bc9fe06fd8
commit e1d39f3bbc
8 changed files with 562 additions and 551 deletions
File diff suppressed because it is too large Load Diff
+4 -1
View File
@@ -5,10 +5,13 @@ import qs.Widgets
import Quickshell
Item {
property var locale: I18n.langCode ? Qt.locale(I18n.langCode) : Qt.locale()
property var now
property color backgroundColor: Color.mPrimary
property color clockColor: Color.mOnPrimary
property color progressColor: Color.mError
anchors.fill: parent
// Digital clock's seconds circular progress
@@ -55,7 +58,7 @@ Item {
NText {
text: {
var t = Settings.data.location.use12hourFormat ? Qt.locale().toString(now, "hh AP") : Qt.locale().toString(now, "HH")
var t = Settings.data.location.use12hourFormat ? locale.toString(now, "hh AP") : locale.toString(now, "HH")
return t.split(" ")[0]
}
+3 -2
View File
@@ -8,6 +8,7 @@ import qs.Widgets
Rectangle {
id: root
property var locale: I18n.langCode ? Qt.locale(I18n.langCode) : Qt.locale()
property ShellScreen screen
// Widget properties passed from Bar.qml for per-instance settings
@@ -62,7 +63,7 @@ Rectangle {
spacing: Settings.data.bar.showCapsule ? -4 : -2
Repeater {
id: repeater
model: Qt.locale().toString(now, formatHorizontal.trim()).split("\\n")
model: locale.toString(now, formatHorizontal.trim()).split("\\n")
NText {
visible: text !== ""
text: modelData
@@ -95,7 +96,7 @@ Rectangle {
anchors.centerIn: parent
spacing: -2
Repeater {
model: Qt.locale().toString(now, formatVertical.trim()).split(" ")
model: locale.toString(now, formatVertical.trim()).split(" ")
delegate: NText {
visible: text !== ""
text: modelData
+3 -1
View File
@@ -9,6 +9,8 @@ import qs.Widgets
NBox {
id: root
property var locale: I18n.langCode ? Qt.locale(I18n.langCode) : Qt.locale()
property int forecastDays: 7
readonly property bool weatherReady: Settings.data.location.weatherEnabled && (LocationService.data.weather !== null)
@@ -102,7 +104,7 @@ NBox {
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
text: {
var weatherDate = new Date(LocationService.data.weather.daily.time[index].replace(/-/g, "/"))
return Qt.locale().toString(weatherDate, "ddd")
return locale.toString(weatherDate, "ddd")
}
color: Color.mOnSurface
}
+4 -2
View File
@@ -18,6 +18,8 @@ Loader {
id: lockScreen
active: false
property var locale: I18n.langCode ? Qt.locale(I18n.langCode) : Qt.locale()
// Track if triggered via deprecated IPC call
property bool triggeredViaDeprecatedCall: false
@@ -342,7 +344,7 @@ Loader {
// Date below
NText {
text: {
var lang = Qt.locale().name.split("_")[0]
var lang = locale.name.split("_")[0]
var formats = {
"de": "dddd, d. MMMM",
"es": "dddd, d 'de' MMMM",
@@ -350,7 +352,7 @@ Loader {
"pt": "dddd, d 'de' MMMM",
"zh": "yyyy年M月d日 dddd"
}
return Qt.locale().toString(Time.date, formats[lang] || "dddd, MMMM d")
return locale.toString(Time.date, formats[lang] || "dddd, MMMM d")
}
pointSize: Style.fontSizeXL
font.weight: Font.Medium
@@ -10,6 +10,8 @@ ColumnLayout {
spacing: Style.marginM
width: 700
property var locale: I18n.langCode ? Qt.locale(I18n.langCode) : Qt.locale()
// Properties to receive data from parent
property var widgetData: null
property var widgetMetadata: null
@@ -200,7 +202,7 @@ ColumnLayout {
// Horizontal
Repeater {
Layout.topMargin: Style.marginM
model: Qt.locale().toString(now, valueFormatHorizontal.trim()).split("\\n")
model: locale.toString(now, valueFormatHorizontal.trim()).split("\\n")
delegate: NText {
visible: text !== ""
text: modelData
@@ -231,7 +233,7 @@ ColumnLayout {
Repeater {
Layout.topMargin: Style.marginM
model: Qt.locale().toString(now, valueFormatVertical.trim()).split(" ")
model: locale.toString(now, valueFormatVertical.trim()).split(" ")
delegate: NText {
visible: text !== ""
text: modelData
+5 -3
View File
@@ -9,6 +9,8 @@ ColumnLayout {
id: root
spacing: Style.marginL
property var locale: I18n.langCode ? Qt.locale(I18n.langCode) : Qt.locale()
NHeader {
label: I18n.tr("settings.location.location.section.label")
description: I18n.tr("settings.location.location.section.description")
@@ -135,15 +137,15 @@ ColumnLayout {
"name": I18n.tr("settings.location.date-time.first-day-of-week.automatic")
}, {
"key": "6",
"name": Qt.locale().dayName(6, Locale.LongFormat)
"name": locale.dayName(6, Locale.LongFormat)
}, // Saturday
{
"key": "0",
"name": Qt.locale().dayName(0, Locale.LongFormat)
"name": locale.dayName(0, Locale.LongFormat)
}, // Sunday
{
"key": "1",
"name": Qt.locale().dayName(1, Locale.LongFormat)
"name": locale.dayName(1, Locale.LongFormat)
} // Monday
]
onSelected: key => Settings.data.location.firstDayOfWeek = parseInt(key)
+7 -6
View File
@@ -5,16 +5,17 @@ import qs.Commons
Rectangle {
id: root
property var locale: I18n.langCode ? Qt.locale(I18n.langCode) : Qt.locale()
property date sampleDate: new Date() // Dec 25, 2023, 2:30:45.123 PM
signal tokenClicked(string token)
color: Color.mSurface
border.color: Color.mOutline
border.width: Style.borderS
radius: Style.radiusM
property date sampleDate: new Date() // Dec 25, 2023, 2:30:45.123 PM
// Signal emitted when a token is clicked
signal tokenClicked(string token)
ColumnLayout {
id: column
anchors.fill: parent
@@ -312,7 +313,7 @@ Rectangle {
NText {
anchors.centerIn: parent
text: Qt.locale().toString(root.sampleDate, modelData.token)
text: locale.toString(root.sampleDate, modelData.token)
color: tokenMouseArea.containsMouse ? Color.mOnPrimary : Color.mSurfaceVariant
pointSize: Style.fontSizeS