Open Bug 1410857 Opened 7 years ago Updated 7 years ago

Switch the order of iteration in Localization.format* methods

Categories

(L20n :: JS Library, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

People

(Reporter: stas, Unassigned)

References

(Blocks 1 open bug)

Details

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.
Blocks: 1365426
You need to log in before you can comment on or make changes to this bug.