From 094853a8fddad1bfead4e2698f4162eb44443e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Legr=C3=A1n?= Date: Mon, 24 Aug 2026 19:59:05 +0200 Subject: [PATCH 1/3] Fix clock/calendar ignoring system locale for weekday and month names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BarWidget.qml used Qt.formatDateTime() and Panel.qml used Qt.formatDate(), neither of which accept a locale argument in QML — both silently fall back to the C locale for token expansion (dddd, MMMM), so the bar clock and calendar popup always show English day/month names regardless of the system's LANG/LC_TIME. Using date.toLocaleDateString()/toLocaleString() with an explicit Qt.locale() fixes this. --- shell/plugins/panels/clock/BarWidget.qml | 2 +- shell/plugins/panels/clock/Panel.qml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/plugins/panels/clock/BarWidget.qml b/shell/plugins/panels/clock/BarWidget.qml index 61cf0bf5c589..deb53f10156e 100644 --- a/shell/plugins/panels/clock/BarWidget.qml +++ b/shell/plugins/panels/clock/BarWidget.qml @@ -57,7 +57,7 @@ BarWidget { } function formatted(date) { - return Qt.formatDateTime(date, activeFormat.replace(/ww/g, Model.isoWeekLiteral(date.getFullYear(), date.getMonth(), date.getDate()))) + return date.toLocaleString(Qt.locale(), activeFormat.replace(/ww/g, Model.isoWeekLiteral(date.getFullYear(), date.getMonth(), date.getDate()))) } // ---- Calendar popup. Shape contract for shell.summon/hide/toggle diff --git a/shell/plugins/panels/clock/Panel.qml b/shell/plugins/panels/clock/Panel.qml index f0dff3ae635c..940a17b281e3 100644 --- a/shell/plugins/panels/clock/Panel.qml +++ b/shell/plugins/panels/clock/Panel.qml @@ -312,7 +312,7 @@ Panel { Text { id: heroDate anchors.verticalCenter: parent.verticalCenter - text: Qt.formatDate(root.today, "MMMM d") + text: root.today.toLocaleDateString(Qt.locale(), "MMMM d") color: heroMouse.containsMouse ? Style.hoverStateColor(root.contentForeground, Color.accent) : root.contentForeground @@ -713,7 +713,7 @@ Panel { // "MAY 2026" and a "SEPTEMBER 2026". width: Style.space(130) horizontalAlignment: Text.AlignHCenter - text: Qt.formatDate(root.viewDate, "MMMM yyyy").toUpperCase() + text: root.viewDate.toLocaleDateString(Qt.locale(), "MMMM yyyy").toUpperCase() color: Qt.darker(root.contentForeground, 1.4) font.family: root.contentFontFamily font.pixelSize: Style.font.body From ad7cf8c6a3975355fb7479066ed03171bd2be0e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Legr=C3=A1n?= Date: Mon, 24 Aug 2026 20:10:20 +0200 Subject: [PATCH 2/3] Address Copilot review: update locale test, use locale-aware uppercase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - test/shell.d/clock-test.sh still asserted the old Qt.formatDate() call for the calendar hero date; updated to assert the new locale-aware toLocaleDateString() call instead. - Added a regression test for BarWidget.qml's toLocaleString(Qt.locale(), ...) call, so the widget's locale fix can't silently regress either. - Panel.qml's month header used toUpperCase(), which is locale-insensitive and mishandles languages with special casing rules (e.g. Turkish dotted capital İ). Switched to toLocaleUpperCase(). --- shell/plugins/panels/clock/Panel.qml | 2 +- test/shell.d/clock-test.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/shell/plugins/panels/clock/Panel.qml b/shell/plugins/panels/clock/Panel.qml index 940a17b281e3..03673796051d 100644 --- a/shell/plugins/panels/clock/Panel.qml +++ b/shell/plugins/panels/clock/Panel.qml @@ -713,7 +713,7 @@ Panel { // "MAY 2026" and a "SEPTEMBER 2026". width: Style.space(130) horizontalAlignment: Text.AlignHCenter - text: root.viewDate.toLocaleDateString(Qt.locale(), "MMMM yyyy").toUpperCase() + text: root.viewDate.toLocaleDateString(Qt.locale(), "MMMM yyyy").toLocaleUpperCase() color: Qt.darker(root.contentForeground, 1.4) font.family: root.contentFontFamily font.pixelSize: Style.font.body diff --git a/test/shell.d/clock-test.sh b/test/shell.d/clock-test.sh index e10d62f12267..4416574dbca5 100755 --- a/test/shell.d/clock-test.sh +++ b/test/shell.d/clock-test.sh @@ -200,6 +200,7 @@ assert(/precision: root\.showsSeconds \? SystemClock\.Seconds : SystemClock\.Min // must reach the label. assert(/showsSeconds: Model\.clockNeedsSeconds\(activeFormat\)/.test(widgetSource), 'clock decides its tick rate from the format it is showing') assert(/onDateChanged: root\.displayDate = date/.test(widgetSource), 'clock repaints the label on every tick') +assert(/return date\.toLocaleString\(Qt\.locale\(\), activeFormat\.replace/.test(widgetSource), 'clock formats the label with the system locale') assert(/setting\("weekStartDay", null\)/.test(panelSource) && /persistSettings\(\{ weekStartDay:/.test(panelSource), 'calendar reads and writes the week start as weekStartDay') assert(/updateEntryInline/.test(panelSource), 'calendar panel persists the week start to shell.json') assert(/function moveMonth\(delta\)/.test(panelSource), 'calendar panel steps between months') @@ -212,7 +213,7 @@ assert(/function close\(\) \{\s*\n\s*setCenterHoverRevealSuppressed\(false\)/.te assert(/width: Math\.max\(calendarScroll\.width, gridColumn\.width\)/.test(panelSource), 'calendar scrolls rather than clipping the grid on a narrow popup') assert(/enabled: !root\.viewingCurrentMonth/.test(panelSource) && /onClicked: root\.goToToday\(\)/.test(panelSource), 'calendar hero returns to today once the view has stepped away') assert(!/clampMonth/.test(panelSource), 'calendar steps freely into future months') -assert(/Qt\.formatDate\(root\.today, "MMMM d"\)/.test(panelSource), 'calendar hero spells out today') +assert(/root\.today\.toLocaleDateString\(Qt\.locale\(\), "MMMM d"\)/.test(panelSource), 'calendar hero spells out today in the system locale') assert(/id: yearLabel/.test(panelSource) && /root\.yearDone/.test(panelSource), 'calendar panel shows the year progress bar') // The memento mori bar is opt-in: double-tapping the year bar asks for an age, From cfa82442efdf87db1c562451d2b1d4d31b6ddf0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Legr=C3=A1n?= Date: Mon, 24 Aug 2026 20:25:11 +0200 Subject: [PATCH 3/3] Address second Copilot review: localize weekday grid headers too labelLocale was hardcoded to Qt.locale("en_US"), so the calendar grid's weekday headers (SUN/MON/TUE...) stayed English even after the month and hero date were made locale-aware, contradicting the PR's premise. Made labelLocale follow the system locale, switched weekdayLabel's casing to toLocaleUpperCase() for the same reason as the month label, and added wiring assertions for both the month label and the weekday headers so neither can silently regress. --- shell/plugins/panels/clock/Panel.qml | 12 ++++++------ test/shell.d/clock-test.sh | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/shell/plugins/panels/clock/Panel.qml b/shell/plugins/panels/clock/Panel.qml index 03673796051d..c7f66ae37ef4 100644 --- a/shell/plugins/panels/clock/Panel.qml +++ b/shell/plugins/panels/clock/Panel.qml @@ -64,10 +64,9 @@ Panel { // convention. Clicking the grid's "W" heading writes the choice back to // shell.json. readonly property int weekStart: Model.normalizedWeekStart(setting("weekStartDay", null), Qt.locale().firstDayOfWeek) - // The interface is English throughout, so day names are not taken from the - // system locale. Where the week starts still is: that is a regional - // convention rather than a translation, and it stays overridable above. - readonly property var labelLocale: Qt.locale("en_US") + // Weekday and month names follow the system locale, matching the bar + // clock's own locale-aware formatting. + readonly property var labelLocale: Qt.locale() readonly property string nextWeekStartLabel: labelLocale.dayName(Model.toggledWeekStart(weekStart), Locale.LongFormat) readonly property var weekdays: Model.weekdayOrder(weekStart) readonly property var weeks: Model.monthGrid(viewYear, viewMonth, weekStart, todayKey) @@ -217,9 +216,10 @@ Panel { setWeekStart(Model.toggledWeekStart(root.weekStart)) } - // English short day names, matching the rest of the interface. + // Short day names in the system locale, with locale-aware casing so + // languages with special casing rules (e.g. Turkish) render correctly. function weekdayLabel(weekday) { - return String(labelLocale.dayName(weekday, Locale.ShortFormat)).toUpperCase() + return String(labelLocale.dayName(weekday, Locale.ShortFormat)).toLocaleUpperCase() } SystemClock { diff --git a/test/shell.d/clock-test.sh b/test/shell.d/clock-test.sh index 4416574dbca5..4d1e62e0efd1 100755 --- a/test/shell.d/clock-test.sh +++ b/test/shell.d/clock-test.sh @@ -214,6 +214,9 @@ assert(/width: Math\.max\(calendarScroll\.width, gridColumn\.width\)/.test(panel assert(/enabled: !root\.viewingCurrentMonth/.test(panelSource) && /onClicked: root\.goToToday\(\)/.test(panelSource), 'calendar hero returns to today once the view has stepped away') assert(!/clampMonth/.test(panelSource), 'calendar steps freely into future months') assert(/root\.today\.toLocaleDateString\(Qt\.locale\(\), "MMMM d"\)/.test(panelSource), 'calendar hero spells out today in the system locale') +assert(/root\.viewDate\.toLocaleDateString\(Qt\.locale\(\), "MMMM yyyy"\)\.toLocaleUpperCase\(\)/.test(panelSource), 'calendar month label spells out the month in the system locale') +assert(/labelLocale: Qt\.locale\(\)/.test(panelSource), 'calendar weekday grid headers follow the system locale') +assert(/labelLocale\.dayName\(weekday, Locale\.ShortFormat\)\)\.toLocaleUpperCase\(\)/.test(panelSource), 'calendar weekday grid headers use locale-aware casing') assert(/id: yearLabel/.test(panelSource) && /root\.yearDone/.test(panelSource), 'calendar panel shows the year progress bar') // The memento mori bar is opt-in: double-tapping the year bar asks for an age,