How do I reinitialize bootstrap tooltip so that the text is translated when language is changed using i18n?

Viewed 2064

I'm using bootstrap tooltips and my page is in 2 languages. I'm using jquery i18n to change the language. I need to change tooltip text when language is changed.

I have succcessfully changed the title attribute for my inputs with data-i18n=[title]inputhelperand I can see it changes because the default html title shows different text than my bootstrap tooltip.

function updateContent() {
  $('.content').localize();
  $('[data-toggle="tooltip"]').tooltip('update');
}

This is what I tried to do to update the tooltip element so it would have the new text but it didn't work.

Now I think what I need to do is reinitialize tooltips but can't quite figure out where exacty and how exactly I would do that. Any advice on how to translate those bootstrap tooltips with i18n would be greatly appreciated.

EDIT: this is how I know that the title attribute value changes: title attribute value change

EDIT2: I was actually able to figure it out after some trial and error. Here's how I did it:

 function updateContent() {
  $('.content').localize();
  $('[data-toggle="tooltip"]').tooltip('dispose');
  $('[data-toggle="tooltip"]').tooltip();  
}
0 Answers
Related