Repository navigation
Fix clock/calendar not respecting system locale (day/month names) - #8085
ivanlegranbizarro wants to merge 3 commits into
Conversation
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.
There was a problem hiding this comment.
Pull request overview
Localizes clock and calendar date names using the system Qt locale.
Changes:
- Uses locale-aware formatting for the bar clock.
- Localizes calendar hero and month 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 3 comments.
| File | Description |
|---|---|
shell/plugins/panels/clock/Panel.qml |
Localizes calendar date labels. |
shell/plugins/panels/clock/BarWidget.qml |
Localizes bar clock formatting. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- 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().
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
shell/plugins/panels/clock/Panel.qml:315
- The popup still formats its weekday headings through the hard-coded
Qt.locale("en_US")(labelLocaleat lines 67–70 andweekdayLabelat lines 220–222). Withes_ES, this produces a localized month beside EnglishMON/TUEheadings, contrary to the PR's claim that the calendar's weekday/month names respect the system locale. Keep the English locale for the prose tooltip if needed, but format the grid headings withQt.locale()and locale-aware casing.
text: root.today.toLocaleDateString(Qt.locale(), "MMMM d")
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.
|
Closing this — while digging into locale handling more broadly I found #6988 (merged 9 days ago), which deliberately reverted this exact kind of localization: As stated there: "a real system-wide translation is a separate future project" — not something to patch in widget by widget. There's an open feature request for that (#7284) and a couple of in-progress attempts at a full i18n system (#7955, #7434), which is the right place for this kind of change to land. Given that, going forward with this PR (or expanding it into a broader translation fix) would just work against a very recent, explicit maintainer decision. Closing rather than pushing more changes against that grain. |
Bar clock and calendar popup always show English weekday/month names, even with LANG set to a non-English locale (e.g. es_ES.UTF-8).
Root cause:
BarWidget.qmlusesQt.formatDateTime(date, format)andPanel.qmlusesQt.formatDate(date, format). Neither QML global accepts a locale argument, so both fall back to the C locale for token expansion (dddd, MMMM) regardless of the user's system locale.Fix: use
date.toLocaleString(Qt.locale(), format)/date.toLocaleDateString(Qt.locale(), format)instead, which do accept an explicit locale.Tested manually with LANG=es_ES.UTF-8 — bar clock and calendar popup now show localized weekday/month names.