39 lines
No EOL
957 B
JavaScript
39 lines
No EOL
957 B
JavaScript
// 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: "lang",
|
|
language: currentLang,
|
|
});
|
|
}
|
|
|
|
function refreshLoc() {
|
|
localize(currentLang);
|
|
}
|
|
|
|
// Function to fill a data-localize attribute and update DOM
|
|
function setLocalizeDataAttr(className, dataValue) {
|
|
$("#" + className)
|
|
.data("localize", dataValue)
|
|
.attr("data-localize", dataValue);
|
|
}
|
|
|
|
function localize(lang) {
|
|
$("[data-localize]")
|
|
.localize("main", { pathPrefix: "lang", language: lang })
|
|
.localize("books", { pathPrefix: "lang", language: lang });
|
|
currentLang=lang;
|
|
} |