Description
Fluent is designed around the concept of strong error fallbacking. The core idea behind it is that we can't assume everything will always go smooth and if errors happen, we want to be as resilient as possible. Much more like HTML and CSS than XML or JS.
The error recovery is a strong part of the resource format in Fluent, allowing us to recover from an error in any message with the next message.
This may be important when we decide on whether we want to specify resource format or just pattern format because some design decisions around syntax were driven in Fluent by the desire to strengthen the recovery algorithm (which sigils to use where may matter if you want to be able to recover).
But even within a single pattern, there are multiple error scenarios that I'd like us to consider specifying:
- Formatter error
key = You have { NUMBER($emails) } unread emails
If NUMBER
fails for some reason, we should be able to display something meaningful to the user. I suggest we ensure that each variable can be displayed without a formatter, even in a dummy way. So the result here could be You have 5 unread emails
where 5
would be western arabic numerals 5
irrelevant of the locale.
Similarly date could be formatted as ISO date.
- Missing/broken variable
If a localizer attempts to use a variable and its missing, we could still format the message: You have $emailCount unread emails
is more meaningful than fully missing message
- Unresolved selector
If the selector fails to resolve, we should have a way to select a "default" variant. In Fluent we denote it with *
, but it could be "the first", "the last" or one named "other" which could be mandatory.
In all of those scenarios (and probably several others I failed to list), I'd like us to report the partially formatted message and errors so that higher level API can decide whether to display this partially formatted message or fallback on the next locale in the hopes that it'll format properly.
In Fluent our plan (not yet implemented) was to design the behavior of fallbacking depending on severity of errors and if all locales in the chain fail, then display the partially formatted message from the first locale.