Skip to content

Backend/i18n: Support localized datetime formats#8574

Merged
tristanlabelle merged 8 commits into
developfrom
backend/feature/loc-datetime-formats
May 26, 2026
Merged

Backend/i18n: Support localized datetime formats#8574
tristanlabelle merged 8 commits into
developfrom
backend/feature/loc-datetime-formats

Conversation

@tristanlabelle

@tristanlabelle tristanlabelle commented May 14, 2026

Copy link
Copy Markdown
Contributor

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.

image

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 LocalizationContext the job of resolving the babel.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

  • Added tests for any new code or added a regression test if fixing a bug
  • Run the backend locally and it works
  • Added migrations if there are any database changes, rebased onto develop if necessary for linear migration history

For maintainers

  • Maintainers can push commits to my branch
  • Maintainers can merge this PR for me

@vercel

vercel Bot commented May 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
couchers Ready Ready Preview May 26, 2026 8:16pm

Request Review

Comment thread app/backend/src/couchers/i18n/context.py Outdated
Comment thread app/backend/src/couchers/i18n/context.py Outdated
Comment thread app/backend/src/tests/test_localize.py
aapeliv
aapeliv previously approved these changes May 25, 2026

@aapeliv aapeliv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i'll trust you on this one

@tristanlabelle
tristanlabelle force-pushed the backend/feature/loc-datetime-formats branch from c45f0cb to 2deddd4 Compare May 26, 2026 20:11
@tristanlabelle

Copy link
Copy Markdown
Contributor Author

Rebased to merge with the feature flags change.

@tristanlabelle
tristanlabelle enabled auto-merge (squash) May 26, 2026 20:12
@tristanlabelle
tristanlabelle disabled auto-merge May 26, 2026 20:13
@tristanlabelle
tristanlabelle merged commit 85a283a into develop May 26, 2026
5 checks passed
@tristanlabelle
tristanlabelle deleted the backend/feature/loc-datetime-formats branch May 26, 2026 20:29
@github-actions github-actions Bot added the release notes: pending Add to stuff that should be included in release notes label May 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📝 Release Notes

This PR should be included in the release notes.

Suggested release note:

Improved localized date and time formatting in push notifications to make event and host request details clearer and more natural
🤖 Bot Debug Information

Model: couchers.openai.gpt-5.4
Decision: include
Reasoning: This PR mainly improves how dates and times are formatted in notifications, which is a noticeable user-facing polish improvement: push notifications for events and host requests now use more natural localized formats, including omitting unnecessary years and adding weekdays where helpful. While much of the work is backend i18n infrastructure, it results in clearer notifications that users will see.

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

Labels

release notes: pending Add to stuff that should be included in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backend/i18n: Support specifying short/long date formats

4 participants