Repository navigation
Fix clock widget to respect system locale for date formatting - #8606
JDavidCarreno wants to merge 2 commits into
Conversation
Qt.formatDateTime() and Qt.formatDate() in QML internally call QDateTime::toString() which uses the C locale (English) for format specifiers like dddd (weekday), MMMM (month), and AP (AM/PM), completely ignoring LANG, LC_TIME, and QLocale::system(). Replace with Qt.locale().toString() which respects the system locale, so the clock displays day/month names and AM/PM in the user's language. Fixes locale formatting for all non-English users.
There was a problem hiding this comment.
Pull request overview
Localizes clock and calendar date formatting using the system locale.
Changes:
- Localizes bar clock formatting.
- Localizes calendar month and date labels.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
shell/plugins/panels/clock/BarWidget.qml |
Uses locale-aware clock formatting. |
shell/plugins/panels/clock/Panel.qml |
Uses locale-aware calendar labels. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| width: Style.space(130) | ||
| horizontalAlignment: Text.AlignHCenter | ||
| text: Qt.formatDate(root.viewDate, "MMMM yyyy").toUpperCase() | ||
| text: Qt.locale().toString(root.viewDate, "MMMM yyyy").toUpperCase() |
| id: heroDate | ||
| anchors.verticalCenter: parent.verticalCenter | ||
| text: Qt.formatDate(root.today, "MMMM d") | ||
| text: Qt.locale().toString(root.today, "MMMM d") |
Replace .toUpperCase() with .toLocaleUpperCase(Qt.locale()) so that locale-specific casing rules are respected (e.g., Turkish dotted I). Also update clock-test.sh to match the new Qt.locale().toString() calls and add test coverage for the month header locale-aware uppercasing.
|
Updated with the requested changes:
All shell tests pass ( |
|
Automated duplication check: this pull request looks similar to #7173, which covers the same clock locale names. I keep that one open and close this one to consolidate review. If you feel this is the wrong decision, please open the PR again with a note on the difference. |
Summary
Replace / with in the clock widget so that day names, month names, and AM/PM markers respect the user's system locale.
Problem
and in QML internally call , which always uses the C locale (English) for format specifiers like
dddd(weekday),MMMM(month), andAP(AM/PM). It completely ignoresLANG,LC_TIME, andQLocale::system().This means all non-English users see the clock in English regardless of their system locale.
Example
With
LANG=es_ES.UTF-8:Thursday, 27 August 9:51 A. M.jueves, 27 agosto 9:51 AMChanges
Three call sites modified:
shell/plugins/panels/clock/BarWidget.qmlQt.formatDateTime(date, format)Qt.locale().toString(date, format)shell/plugins/panels/clock/Panel.qmlQt.formatDate(date, "MMMM d")Qt.locale().toString(date, "MMMM d")shell/plugins/panels/clock/Panel.qmlQt.formatDate(date, "MMMM yyyy")Qt.locale().toString(date, "MMMM yyyy")Compatibility
The codebase already uses
Qt.locale()elsewhere (e.g.,Panel.qmlline 66 forfirstDayOfWeek,SpeedTestOverlay.qmlfor number formatting), so this fix is consistent with existing patterns.Model.jsis explicitly locale-free and is not affected.Fixes #8600