Repository navigation
fix(clock): use system locale for calendar weekday labels - #7212
markbus-ai wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the clock panel calendar to use the user’s system locale for weekday labels, improving localization while preserving existing week-start override behavior.
Changes:
- Switch weekday label locale from a hard-coded
en_USlocale to the system locale (Qt.locale()). - Update comments to reflect the new localization behavior for day names.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // language. The week start is a regional convention rather than a | ||
| // translation, and it stays overridable above. | ||
| readonly property var labelLocale: Qt.locale() | ||
| readonly property string nextWeekStartLabel: labelLocale.dayName(Model.toggledWeekStart(weekStart), Locale.LongFormat) |
The calendar popup weekday headers were hardcoded to Qt.locale("en_US"),
ignoring the user's system locale. This caused English day names (MO, TU,
WE, etc.) to appear even for non-English users, while the rest of the
clock widget already respected the system locale.
Change Qt.locale("en_US") to Qt.locale() so weekday names resolve from
the system environment, consistent with the month names and time formats
used elsewhere in the same widget.
Also fix a pre-existing bug where Model.toggledWeekStart() returns a
0-based JS index (0=Sunday) but Locale.dayName() expects Qt's 1-7 range.
Add normalization before the dayName() call.
2f44042 to
6f08a32
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
shell/plugins/panels/clock/Panel.qml:80
- The conversion logic for “model day index →
Qt.DayOfWeek” is embedded in the QML file, which makes it easier for future call sites to re-implement (and possibly mismatch) the same mapping. If other code paths also need consistent day-of-week conversions, consider moving this intoModel(e.g., a helper that returns a guaranteedQt.DayOfWeek), then bindnextWeekStartDayOfWeekto that helper. This reduces duplication and centralizes the mapping definition.
// Normalize toggledWeekStart (0-based JS index) to Qt.DayOfWeek range (1-7)
// before passing to dayName(), which expects Qt.Sunday(1)..Qt.Saturday(7).
readonly property int nextWeekStartDayOfWeek: {
const toggled = Model.toggledWeekStart(weekStart)
// Already in Qt range (1-7)
if (toggled >= Qt.Sunday && toggled <= Qt.Saturday) return toggled
// JS range (0-6) — shift to Qt range
if (toggled >= 0 && toggled <= 6) return toggled + 1
return weekStart
}
shell/plugins/panels/clock/Panel.qml:72
- The comment says
toggledWeekStartis a “0-based JS index,” but the implementation explicitly supports both 0–6 and 1–7 inputs. To avoid misleading future readers, update the comment to reflect the accepted ranges (or, ifModel.toggledWeekStart()is expected to always return 0–6, consider removing the 1–7 branch and enforcing that invariant in the model).
// Normalize toggledWeekStart (0-based JS index) to Qt.DayOfWeek range (1-7)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
shell/plugins/panels/clock/Panel.qml:83
- This fallback re-reads
Qt.locale()instead of using the already-definedlabelLocale. UsinglabelLocale.firstDayOfWeekkeeps the locale source consistent within the component and avoids subtle inconsistencies if locale-dependent values are evaluated at different times.
return Qt.locale().firstDayOfWeek
| // before passing to dayName(), which expects Qt.Sunday(1)..Qt.Saturday(7). | ||
| readonly property int nextWeekStartDayOfWeek: { | ||
| const toggled = Model.toggledWeekStart(weekStart) | ||
| // Already in Qt range (1-7) | ||
| if (toggled >= Qt.Sunday && toggled <= Qt.Saturday) return toggled | ||
| // JS range (0-6) — shift to Qt range | ||
| if (toggled >= 0 && toggled <= 6) return toggled + 1 | ||
| // Fallback: normalize weekStart too so this property always returns | ||
| // a valid Qt.DayOfWeek value for dayName(). | ||
| if (weekStart >= Qt.Sunday && weekStart <= Qt.Saturday) return weekStart |
|
Closing per maintainer direction: dhh intentionally hardcoded English day names in #6988 as part of a consistent English-only shell design. A proper i18n system is a separate future project. Will handle this via a local post-update hook instead. |
Closes #7211
Summary
Qt.locale()instead ofQt.locale("en_US")for calendar weekday labelsChanges
shell/plugins/panels/clock/Panel.qmllabelLocalefrom hardcodeden_USto system localeTest Plan