// In a browser where the language is set to French localize(); var currentLang; // You can also override the language detection, and pass in a language code //$("[data-localize]").localize("main", { language: "fr" }); function changeLangFR() { localize("fr"); } // This code defines a function that sets the language to English. function changeLangEN() { localize("en"); } function refreshBooks() { $("[data-localize]").localize("books", { pathPrefix: "data", language: currentLang, }); } function refreshLoc() { localize(currentLang); } // Function to fill a data-localize attribute and update DOM function setLocalizeDataAttr(id, dataValue) { const all = $('[id="' + id + '"]'); all.each(function() { console.log(this.id) $(this).data("localize", dataValue).attr("data-localize", dataValue); }); } function localize(lang) { $("[data-localize]") .localize("main", { pathPrefix: "lang", language: lang }) .localize("books", { pathPrefix: "data", language: lang }); currentLang=lang; }