Skip to content

fix(clock): use system locale for calendar weekday labels - #7212

Closed
markbus-ai wants to merge 2 commits into
omacom:quattrofrom
markbus-ai:fix/calendar-locale
Closed

markbus-ai wants to merge 2 commits into
omacom:quattrofrom
markbus-ai:fix/calendar-locale

Conversation

@markbus-ai

Copy link
Copy Markdown
Contributor

Closes #7211

Summary

  • Use Qt.locale() instead of Qt.locale("en_US") for calendar weekday labels
  • Weekday names (MO, TU, WE, etc.) now follow the system locale
  • Consistent with how month names and time formats are already rendered

Changes

File Change
shell/plugins/panels/clock/Panel.qml Changed labelLocale from hardcoded en_US to system locale

Test Plan

  • Verified change compiles without errors
  • Manually tested the calendar popup shows localized weekday names
  • Confirmed week start toggle still works correctly

Copilot AI balanced review requested due to automatic review settings August 17, 2026 02:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_US locale 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.

Comment thread shell/plugins/panels/clock/Panel.qml Outdated
// 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.
@markbus-ai
markbus-ai force-pushed the fix/calendar-locale branch from 2f44042 to 6f08a32 Compare August 17, 2026 02:56
Copilot AI review requested due to automatic review settings August 17, 2026 02:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 into Model (e.g., a helper that returns a guaranteed Qt.DayOfWeek), then bind nextWeekStartDayOfWeek to 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 toggledWeekStart is 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, if Model.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)

Comment thread shell/plugins/panels/clock/Panel.qml Resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 17, 2026 02:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-defined labelLocale. Using labelLocale.firstDayOfWeek keeps the locale source consistent within the component and avoids subtle inconsistencies if locale-dependent values are evaluated at different times.
    return Qt.locale().firstDayOfWeek

Comment on lines +72 to +81
// 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
@markbus-ai

Copy link
Copy Markdown
Contributor Author

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.

@markbus-ai markbus-ai closed this Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calendar weekday labels hardcoded to English instead of using system locale

2 participants