Open jphblais opened 8 years ago
https://github.com/wikimedia/jquery.i18n/blob/master/README.md#data-api
$.fn.i18n is always about replacing text of the element. If you want to change the html of the element, you may want to use:
$(selector).html($.i18n(messagekey))
Thank you for your fast answer. For other, here is how I resolved it:
function doI18n() {
var elements = $('[data-i18n]');
elements.each(function(index, value) {
var messageKey = $(value).attr('data-i18n');
var txt = $.i18n(messageKey);
$(elements[index]).html(txt);
});
}
See also proposed pull: https://github.com/wikimedia/jquery.i18n/pull/112
I have a message containing and HTML element like "test
text", but my "br" is displayed as escaped element. How to avoid elements escaping? I'm using the transparent $('[data-i18n]').i18n(); technique to translate all the content in my single page app.