Skip to content

fix(core): load the user's moment.js locale - #67136

Open
skjnldsv wants to merge 1 commit into
masterfrom
fix/moment-locale
Open

skjnldsv wants to merge 1 commit into
masterfrom
fix/moment-locale

Conversation

@skjnldsv

Copy link
Copy Markdown
Member

Summary

Since the core bundle moved to Vite (4a4ba35), OC.Util.formatDate() and OC.Util.relativeModifiedDate() ignore the user's locale. moment resolves to its ES build, while moment/min/locales.js registers its locales on the CommonJS build, so moment.locale('de') silently stays English. All 130+ locales still load with core-main on every page.

Now only the user's locale is loaded from moment/dist/locale, which registers on the same instance. It runs in initCore() because the chunk URL is resolved through OC.filePath.

German user, OC.Util.formatDate(…, 'LLLL'):

stable35 master this PR
Samstag, 28. November 2026 13:00 Saturday, November 28, 2026 1:00 PM Samstag, 28. November 2026 13:00

Every page loads 74 KB gzipped less. Until the locale chunk arrives, these deprecated helpers answer in English. The unit test covers the loader: vitest resolves both moment entries to one instance, so the mismatch itself only shows in the Vite build, which I checked in the browser.

Relates to nextcloud/standards#17

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

👾 This pull request was assisted by Claude Code, commits carry an Assisted-by trailer.

Since the core bundle moved to Vite, `moment` resolves to its ES build
while `moment/min/locales.js` registers on the CommonJS build, so
OC.Util.formatDate() ignored the user's locale. Load only the user's
locale from `moment/dist/locale` instead of bundling all of them.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
@skjnldsv
skjnldsv requested a review from a team as a code owner November 28, 2026 18:45
@skjnldsv skjnldsv added this to the Nextcloud 36 milestone Nov 28, 2026
@skjnldsv
skjnldsv requested review from pringelmann and susnux and removed request for a team November 28, 2026 18:45
@skjnldsv skjnldsv self-assigned this Nov 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant