Skip to content

Fix clock widget to respect system locale for date formatting - #8606

Closed
JDavidCarreno wants to merge 2 commits into
omacom:quattrofrom
JDavidCarreno:fix/clock-locale-formatting
Closed

JDavidCarreno wants to merge 2 commits into
omacom:quattrofrom
JDavidCarreno:fix/clock-locale-formatting

Conversation

@JDavidCarreno

Copy link
Copy Markdown

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), and AP (AM/PM). It completely ignores LANG, LC_TIME, and QLocale::system().

This means all non-English users see the clock in English regardless of their system locale.

Example

With LANG=es_ES.UTF-8:

  • Before: Thursday, 27 August 9:51 A. M.
  • After: jueves, 27 agosto 9:51 AM

Changes

Three call sites modified:

File Line Before After
shell/plugins/panels/clock/BarWidget.qml 60 Qt.formatDateTime(date, format) Qt.locale().toString(date, format)
shell/plugins/panels/clock/Panel.qml 315 Qt.formatDate(date, "MMMM d") Qt.locale().toString(date, "MMMM d")
shell/plugins/panels/clock/Panel.qml 716 Qt.formatDate(date, "MMMM yyyy") Qt.locale().toString(date, "MMMM yyyy")

Compatibility

The codebase already uses Qt.locale() elsewhere (e.g., Panel.qml line 66 for firstDayOfWeek, SpeedTestOverlay.qml for number formatting), so this fix is consistent with existing patterns. Model.js is explicitly locale-free and is not affected.

Fixes #8600

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.
Copilot AI balanced review requested due to automatic review settings August 27, 2026 15:09

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

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.

Comment thread shell/plugins/panels/clock/Panel.qml Outdated
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.
@JDavidCarreno

Copy link
Copy Markdown
Author

Updated with the requested changes:

  1. Locale-aware uppercasing: Replaced .toUpperCase() with .toLocaleUpperCase(Qt.locale()) in Panel.qml line 716 so that locale-specific casing rules are respected (e.g., Turkish dotted I).

  2. Test fixes: Updated clock-test.sh to match the new Qt.locale().toString() calls and added test coverage for the month header locale-aware uppercasing.

All shell tests pass (./test/shell).

@bjarneo

bjarneo commented Sep 21, 2026

Copy link
Copy Markdown
Member

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.

@bjarneo bjarneo closed this Sep 21, 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.

Clock widget ignores system locale — always shows English day/month/AM-PM

3 participants