On 12/04/16 15:31, Joe Walker wrote:
Axel Hecht wrote:

...
Our analysis leads us to:
React and l20n.js-with-mutation-observers are two orthogonal libraries.

I think this gets to the heart of the matter. React and l20n both change
the DOM, and both do it without taking account of each other.
I used the word "orthogonal" in a stronger sense. The thing that one does doesn't destroy the other and vice versa.

The best we can hope for is a double update where React updates the DOM
without translated strings, and then l20n comes along and fixes things. [1]
Sorry, but our experiment shows that that doesn't happen. The jsx generates the DOM elements, and l20n.js adds text nodes and attributes. Only in cases where we expect retranslation to be required, react unsets our DOM mods. Gandalf refers to the spec of mutation observers that they're defined to not trigger layout inbetween, so there's also no double layout.
The worst case is that this update doesn't happen properly, and we're left
with things out of sync and a broken website either through a react error
or a translation error. [2]
Same as above.

My hunch is that working with the synchronous react render cycle (rather
than against it) is going to be much less painful long term. We can get
that either by loading 2 sets of strings at startup, or by using a redux
action to indicate a string update.
A hunch doesn't advance the conversation here. We're confident that we addressed your concerns, and if there are open items, I'd expect to see a demo that shows them.

Axel

Joe.

[1]: Reflecting on the best case scenario: Many people put lots of effort
into using Immutable and/or shouldComponentUpdate to avoid unnecessary
renders, so I'm not keen on an architectural decision to double (or more?)
the cost of any render that uses translated strings.
[2]: Thanks for the JSBin demo. I should have beeen clearer. React is
making changes to the DOM without thinking of l20n at all. The changes
could be sweeping (e.g. for a tab dialog), or rapid (e.g. an animation) or
both together. My concern is that interleaving of events from both react
and l20n is going to leave things untranslated or otherwise out of sync.
Maybe we can prove there is no possibility that this will go wrong, but [1]
is still a big issue.


_______________________________________________
tools-l10n mailing list
[email protected]
https://lists.mozilla.org/listinfo/tools-l10n

Reply via email to