Skip to content

fix(admin): show dates in the backend locale - #3826

Open
Vondry wants to merge 1 commit into
bolt:6.1from
Vondry:fix/luxon-admin-locale
Open

Vondry wants to merge 1 commit into
bolt:6.1from
Vondry:fix/luxon-admin-locale

Conversation

@Vondry

@Vondry Vondry commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Admin dates ignore the backend locale. Relative labels such as "7 days ago" and the listing dates follow the browser's language, and their tooltips are English unless the backend locale is also a content locale.

Part of localizing the admin UI, alongside #3825.

Changes

  • assets/js/locale.js sets Luxon's default locale from <html lang>, converting codes like pt_BR to pt-BR. Invalid locales keep the browser's locale.
  • The relative_datetime macro and value-only date fields pass app.request.locale to localdate, which otherwise falls back to the content locale.
  • <html lang> uses app.request.locale (as Translate the html field editor into the backend locale聽#3825 does) and outputs a valid language tag.

Testing

time-test.mp4

Dates in the admin UI ignored the backend locale. Relative labels such as
"7 days ago" and the Vue listing dates are formatted by Luxon, which was
never given a locale and used the browser's. Their tooltips are rendered
by the localdate filter, which without a locale falls back to the current
content locale. Admin locales that are not content locales, like cs, got
English.

- locale.js sets Luxon's default locale from <html lang>, converting
  Bolt codes like pt_BR to BCP 47. An invalid locale would make Luxon
  throw on every date it formats, so those keep the browser's locale.
- <html lang> uses app.request.locale, the locale the backend is
  translated into, instead of the user's saved locale, and outputs it as
  a valid language tag (pt-BR).
- The relative_datetime macro and value-only date fields (media edit
  page) pass app.request.locale to localdate. A locale passed by the
  caller still takes precedence.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant