Backend/i18n: Localize date/times with Babel#7884
Backend/i18n: Localize date/times with Babel#7884tristanlabelle wants to merge 2 commits intodevelopfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
aapeliv
left a comment
There was a problem hiding this comment.
Very happy to have plural rules from CLDR, and very supportive of this in general!
A few other comments:
- We will now need to start implementing full locales, not just language in what the user can specify somehow on the settings page; as e.g.
en_USis different fromen_AU. I guess this can wait though and is no worse than hardcoding it the way we have it now. (I have a personal pet peeve on some of the date and time formatting stuff etc; but that's not important.) - I'm weary of the time zone names. I'm worried the time zone names in babel make sense to someone in a locale in their own local (pun intended) environment, but not as much sense in a global context. I kind of feel like our travel-centric community is on average much more comfortable with timezones and would for instance prefer to have the UTC offset in the email compared to just "United Kingdom Time" or the super vague "Eastern Time" (in Australia we have "Eastern Time" which is very different from US ET, though often we'll call it "Australian Easter Time" which is its full name).
- [Extra Random thought]: we could actually have separate
en_AU/en_US/en_GB/etc translations pretty easily with LLMs, though that's probably overkill.
|
@aapeliv Cool, any of these are blockers?
|
|
@aapeliv It turns out it we can't really state that all times in the email are in a timezone as an UTC offset because the email could reference dates in the past or the future that cross the daylight savings boundary. To make the timezone more readable, we can add the example city in parens (this is provided by the CLDR), so for example we could display name = get_timezone_name(timezone, locale=locale)
location = get_timezone_location(timezone, locale=locale, return_city=True)
return f"{name} ({location})" if location != name else name |
I think better to leave it as the localized timezone name. I suppose that is the best option here. On the UTC offset: that's fair but also I don't think it's that big a correctness issue. |
aapeliv
left a comment
There was a problem hiding this comment.
lgtm, let's think about the locale input further as we go
Localizes dates, times, datetimes and timezone names using the Babel library, which bundles a serialized Unicode CLDR. Also removes the manual implementation of Unicode plural rules in favor of Babel's. This will be visible in dates in push notifications, and emails once they are localized.
Fixes #7590
Testing
Added tests and ran existing ones.
Emails are not yet localized but we can see the timezone is now nice text:
Compare with previously:
Backend checklist
developif necessary for linear migration historyFor maintainers