Switch the order of iteration in Localization.format* methods



2 years ago
2 years ago


(Reporter: stas, Unassigned)


(Blocks 1 bug)




2 years ago
Right now, the formatting methods of Localization iterate over the the list of MessageContexts first and the list of requested ids second. In other words, for each context we try to retrieve a full list of translations. Once we have that list, we need logic to discover if there have been any errors and to decide if fallback is required.

This approach has a few limitations:

  - it's hard to implement the fallback to the id in case a message is missing from all contexts (bug 1410849),
  - ideally, the fallback to the id would only happen if the bindings (e.g. fluent-dom) allow it; for some known lists of DOM elements the bindings might prefer to keep the value empty and fall back in one of the attributes.
  -it forces a two-pass iteration in fluent-dom: first we iterate to get translations for all ids across all known contexts, then we iterate over all DOM elements to apply the translations.

I'd like to propose an alternative:  let's switch the order of iteration to first iterate over all ids (all DOM elements in fluent-dom) and the for each id, use mapContext to get the best context for this id.


2 years ago
Blocks: 1365426
You need to log in before you can comment on or make changes to this bug.