Skip to content

Localize weekday and month names in the bar clock - #6941

Closed
dhh wants to merge 1 commit into
quattrofrom
fix-clock-locale
Closed

dhh wants to merge 1 commit into
quattrofrom
fix-clock-locale

Conversation

@dhh

@dhh dhh commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Qt.formatDateTime(date, format) renders dddd/ddd/MMMM/MMM from the C locale in Qt 6 regardless of Qt.locale(), so the bar clock stayed English whatever LANG said. The calendar popup already localizes through Qt.locale().dayName, so the bar and its own popup disagreed.

date.toLocaleString(Qt.locale(), format) honours the locale and takes the same format string.

Format equivalence

Checked all eight horizontal and four vertical presets from Model.js through both calls:

  • Under the C locale every one is byte-identical, including the 'W'ww and ''yy quoted literals and the embedded newlines.
  • Under de_DE the day and month names localize as expected.

The one intended behavioral change is AP, which now renders the locale's own designator instead of a hard-coded PM.

Verified in the running UI

test/shell.d/clock-test.sh is deliberately Qt-free, so this line is not unit-testable. Verified in a throwaway VM instead — Omarchy 3.8.0 installed from the ISO, upgraded to Quattro, de_DE.UTF-8 generated, LANG set, shell restarted:

Preset Rendered
dddd HH:mm Samstag 07:29
dddd HH:mm (Thursday, worst-case weekday) Donnerstag 14:05
d MMMM 'W'ww yyyy (December) 3 Dezember W49 2026
dd\nMMM\n'W'ww\n''yy (vertical bar) 03 / Dez. / W49 / '26

No clipping, no layout shift, neighbouring widgets unaffected, and the quoted literals survive in both orientations.

Closes #6934

— 🤖 Claude, posting on behalf of @dhh

Qt.formatDateTime renders dddd and MMMM from the C locale whatever Qt.locale()
says, so the clock stayed English while its own calendar popup, which already
goes through Qt.locale(), did not. All twelve shipped presets render identically
under an English locale.

Closes #6934

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings August 15, 2026 09:12

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 bar clock weekday/month names using the active Qt locale.

Changes:

  • Replaces Qt.formatDateTime with locale-aware Date.toLocaleString.
  • Preserves existing format and ISO-week substitution behavior.

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.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

return Qt.formatDateTime(date, activeFormat.replace(/ww/g, Model.isoWeekLiteral(date.getFullYear(), date.getMonth(), date.getDate())))
// toLocaleString, not Qt.formatDateTime: the latter renders dddd/MMMM from
// the C locale regardless of Qt.locale(), so day and month names stay English.
return date.toLocaleString(Qt.locale(), activeFormat.replace(/ww/g, Model.isoWeekLiteral(date.getFullYear(), date.getMonth(), date.getDate())))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verified in the running UI. I did it in a throwaway VM rather than on a live desktop: installed Omarchy 3.8.0 from the ISO, upgraded it to Quattro, generated de_DE.UTF-8, patched the clock widget in /usr/share/omarchy, set LANG=de_DE.UTF-8 and restarted the shell.

Horizontal, short preset — Samstag 07:29, centred, no clipping, neighbouring widgets unaffected.

Then set the clock to a Thursday in December to hit the longest German names:

  • dddd HH:mm → Donnerstag 14:05 (longest German weekday, 10 chars vs 9 for Wednesday)
  • d MMMM 'W'ww yyyy → 3 Dezember W49 2026

Vertical bar, dd\nMMM\n'W'ww\n''yy, stacks as 03 / Dez. / W49 / '26 — the abbreviated German month carries a trailing period and still fits the bar width.

No clipping, no layout shift, and the quoted literals survive toLocaleString in both orientations (W49, '26). Screenshots are on the run, happy to attach any of them if useful.

— 🤖 Claude, posting on behalf of @dhh

@dhh

dhh commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing — this went the wrong way.

The shell is English throughout, and a real system-wide translation is a separate future project. Localizing the bar clock to match the calendar made the clock the odd one out; the calendar was the accident.

Replaced by #6988, which takes the calendar's day names from en_US instead. Same underlying inconsistency, fixed in the direction that matches the rest of the OS.

Leaving #6934 open would be misleading, so closing that too with the reasoning.

— 🤖 Claude, posting on behalf of @dhh

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.

Bar clock always shows weekday/month names in English, ignoring system locale (LANG)

2 participants