// In a browser where the language is set to French
$("[data-localize]")
  .localize("main", { pathPrefix: "lang" })
  .localize("books", { pathPrefix: "lang" });
var currentLang;
// You can also override the language detection, and pass in a language code
//$("[data-localize]").localize("main", { language: "fr" });
function changeLangFR() {
  $("[data-localize]")
    .localize("main", {
      pathPrefix: "lang",
      language: "fr",
    })
    .localize("books", {
      pathPrefix: "lang",
      language: "fr",
    });
  currentLang = "fr";
}

// This code defines a function that sets the language to English.
function changeLangEN() {
  $("[data-localize]")
    .localize("main", {
      pathPrefix: "lang",
      language: "en",
    })
    .localize("books", {
      pathPrefix: "lang",
      language: "en",
    });
  currentLang = "en";
}

function refreshBooks() {
  
 $("[data-localize]").localize("books", {
    pathPrefix: "lang",
    language: currentLang,
  });
}

// Function to fill a data-localize attribute and update DOM
function setLocalizeDataAttr(className, dataValue) {
  $("#" + className).data("localize", dataValue).attr("data-localize", dataValue);
}
