Zibi opened up an issue in the Browser Extensions spec repo:
https://github.com/browserext/browserext/issues/54
Before I comment there, I'd like to have a discussion here to align
our views on the subject.
Zibi's message makes it sound like Project Fluent's paradigm is async.
The relevant quote is:
> In the paradigm we propose, getMessage should not be a sync operation. Client side localization may use fallbacks in which case they should be loaded lazily and that in turn means that the API should be async.
I disagree. There's nothing in Project Fluent that requires or forces
async. Moreover I don't think async should be an explicit goal for us.
Fallback messages may be procured on build time or they may be loaded
synchronously or they can be ignored/replaced by the identifier.
The real shortcoming of i18n.getMessage as I see it is that it doesn't
allow any form of branching. No plurals, no genders. Even the fact
that it uses positional arguments is probably OK. Not ideal, but
acceptable.
Given how well implemented the i18n API has become across modern
browsers, I'd like to think how we can improve the existing API within
the constraints of the current, sync paradigm. The existing API solved
a number of challenges: translation loading, CSS localization, and
manifest localization to name a few.
Perhaps there's an avenue here for us to consider: introduce a sync
sister-method called getFormattedMessage(id, namedArgs) which uses the
same logic for translation loading but uses messages.ftl files rather
than message.json? In CSS and manifest files, the __FTL_ prefix could
be used similar to the current __MSG_ one.
This would allow us to start using FTL in Web Extensions without
reinventing the whole workflow and the loading story.
What do you think about this meet-them-half-way approach?
Staś