i18next / i18nextify

enables localization of any page with zero effort.
MIT License
61 stars 21 forks source link

SaveMission only firering at startup #84

Closed ChristophKind closed 6 years ago

ChristophKind commented 6 years ago

Hey,

i have a problem with the saveMissing - Option an dynamic content. When the page loads, everything is fine and saveMissing is fired well. But after 3 seconds some content on my page is loaded dynamicly. I want to fire saveMissing again after the content is loaded into the dom, but nothing happens.

Can you help me?

ChristophKind commented 6 years ago

Oh i also recognized, that the dynamic content isnt translated. Am I missing some option ?

jamuhl commented 6 years ago

Did you check the sample...https://github.com/i18next/i18nextify/blob/master/example/index.html#L95 at least seems to work there

ChristophKind commented 6 years ago

Yes i checked it. Soo, it works if you add new elements with createelement + appendChild. But if you change only the text (innerHtml) of an element it does not work.

Please try it in your example with document.getElementById("testdiv").innerHTML = "New text!";

If this is the only change, the saveMissing url is not called.

jamuhl commented 6 years ago

Yes...changing innerHtml won't work...because it already gone through that element...it's flagged translated.

You would need replace the full element or directly set translated content to innerHmtl using the i18next instance

i18nextify.i18next.t('key', options); -> https://www.i18next.com/translation-function/essentials#accessing-keys

ChristophKind commented 6 years ago

hmm okay. is there no other posibility ?

jamuhl commented 6 years ago

i guess no...you might try around...eventual removing the translated attributes on that element and setting innerHtml afterwards does the trick...idk