Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shell/plugins/panels/clock/BarWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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())))
Comment thread
ivanlegranbizarro marked this conversation as resolved.
Resolved
}

// ---- Calendar popup. Shape contract for shell.summon/hide/toggle
Expand Down
16 changes: 8 additions & 8 deletions shell/plugins/panels/clock/Panel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Comment thread
ivanlegranbizarro marked this conversation as resolved.
Resolved
color: heroMouse.containsMouse
? Style.hoverStateColor(root.contentForeground, Color.accent)
: root.contentForeground
Expand Down Expand Up @@ -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").toLocaleUpperCase()
color: Qt.darker(root.contentForeground, 1.4)
font.family: root.contentFontFamily
font.pixelSize: Style.font.body
Expand Down
6 changes: 5 additions & 1 deletion test/shell.d/clock-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -212,7 +213,10 @@ 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(/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,
Expand Down