Backend/i18n: Externalize fallbacks languages from I18Next#9158
Conversation
MobileInstall the Dev Tool (iOS via TestFlight, iOS Simulator, or Android .apk) here. Scan the QR with your phone camera, or tap Open in Dev Tool on the device, to open this branch in the installed Dev Tool dev client.
Deep linksiOS Android Web (Vercel)View the Vercel web preview for this branch. Backend
Other
|
aapeliv
left a comment
There was a problem hiding this comment.
I feel like this is not quite the right system: now you have different areas of the code worrying about locale lists, which to me shouldn't be the concern of application code?
I feel like what you want here is an "all-or-nothing localization block", where you guarante that every translation there is localized to a given language or fully falls back. We may want a similar one for e.g. notifications (so you don't get a partially translated notification)? Similarly you could imagine you'd want it in an RPC. Though that seems difficult to achieve in cases where you can't fall back and retry with a try-except? It seems it may require some kind of lazy evaluation in most cases?
If you feel this is the best way, I'm also happy with this. But I feel like a cleaner abstraction would be even a limited version of this kind of "localization context/block" that raises if there is a missing translation, but does not contain the local fallback chain, just a boolean basically that it's in an all-or-nothing section, or similar. Then at least we don't need to embed the locale fallback chain in application code.
I convinced myself that having low-level loc APIs take a locale list is the most flexible approach, and that's probably why all the javascript But also currently the date/language/region lookups do not support fallbacks and I'm worried a language could get broken because of this without us realizing. There's no For transational localization, the API would look something like |
aapeliv
left a comment
There was a problem hiding this comment.
thanks for engaging with it. i think your solution here is clean enough, and i'm sure it will evolve over time anyway!
482ea8f to
2d30652
Compare
📝 Release NotesThis PR does not need to be included in release notes. Reason: This PR is an internal backend refactor of the localization fallback system. While it may enable better all-or-nothing localization behavior in the future, it does not by itself introduce a clear user-facing feature, visible UX improvement, or a specific important bug fix that end users would notice now. 🤖 Bot Debug InformationModel: |


Instead of baking the locale fallbacks into the
I18Nextobject, pass a locales list when localizing strings.This allows implementing all-or-nothing localization, say for emails, as follows (pseudocode):
It also splits the responsibility of knowing our fallback chain from the implementation of the I18Next format.
Testing
Updated tests.
Backend checklist
developif necessary for linear migration historyFor maintainers