Backend/i18n: Support localized datetime formats#8574
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
tristanlabelle
force-pushed
the
backend/feature/loc-datetime-formats
branch
from
May 26, 2026 20:11
c45f0cb to
2deddd4
Compare
Contributor
Author
|
Rebased to merge with the feature flags change. |
tristanlabelle
enabled auto-merge (squash)
May 26, 2026 20:12
tristanlabelle
disabled auto-merge
May 26, 2026 20:13
Contributor
📝 Release NotesThis PR should be included in the release notes. Suggested release note: 🤖 Bot Debug InformationModel: |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We only supported one localized datetime format. This isn't quite enough in practice. For example, when we send a push notification about a host request, saying "May 16, 2026" is not ideal: the year is implicit, and it'd be useful to have the day of the week.
This implements multiple datetime formats with an API similar to the frontend's. Python doesn't have Javascript's convenient
Intl.DateTimeFormat, but the Babel library exposes everything from the Unicode CLDR that we need to implement the functionality, even if it gets a little a little gnarly. Hopefully I documented it well.I also changed the defaults a little bit to use long-form month names and omit seconds (both unless requested). This aligns with the frontend and is hopefully less surprising.
I also gave
LocalizationContextthe job of resolving thebabel.Locale, as to not have to do it on every formatting operation.I also leveraged the new feature to tweak datetime formats in push notifications for events and host requests. I didn't change those in emails since I'm working on email changes in parallel.
Fixes #7885, #8490
Testing
Updated and added tests.
Backend checklist
developif necessary for linear migration historyFor maintainers