I haven't looked at this in detail but you could try causing an (artificial) delay between setting the innerHTML and translating - or push the translation into the existing (or another) timeout. That is, allowing the DOM to be fully updated before attempting the translation.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity
." Me Myself & Irene
Validate your HTML