Compare commits
No commits in common. "965e278ba69716d2076a22ffd287e1a9c05b7508" and "209f21535e3da48c85ac507fb5e6cd90a7135ad7" have entirely different histories.
965e278ba6
...
209f21535e
3 changed files with 30 additions and 32 deletions
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
@ -8,5 +8,4 @@
|
||||||
"url": "/./.vscode/spells-schemas.json"
|
"url": "/./.vscode/spells-schemas.json"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stenography.apiKey": "caac2b35-1682-4741-a409-d687f69d9767",
|
|
||||||
}
|
}
|
|
@ -1,16 +1,35 @@
|
||||||
// In a browser where the language is set to French
|
// In a browser where the language is set to French
|
||||||
localize();
|
$("[data-localize]")
|
||||||
|
.localize("main", { pathPrefix: "lang" })
|
||||||
|
.localize("books", { pathPrefix: "lang" });
|
||||||
var currentLang;
|
var currentLang;
|
||||||
// You can also override the language detection, and pass in a language code
|
// You can also override the language detection, and pass in a language code
|
||||||
//$("[data-localize]").localize("main", { language: "fr" });
|
//$("[data-localize]").localize("main", { language: "fr" });
|
||||||
function changeLangFR() {
|
function changeLangFR() {
|
||||||
localize("fr");
|
$("[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.
|
// This code defines a function that sets the language to English.
|
||||||
function changeLangEN() {
|
function changeLangEN() {
|
||||||
localize("en");
|
$("[data-localize]")
|
||||||
|
.localize("main", {
|
||||||
|
pathPrefix: "lang",
|
||||||
|
language: "en",
|
||||||
|
})
|
||||||
|
.localize("books", {
|
||||||
|
pathPrefix: "lang",
|
||||||
|
language: "en",
|
||||||
|
});
|
||||||
|
currentLang = "en";
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshBooks() {
|
function refreshBooks() {
|
||||||
|
@ -21,7 +40,9 @@ function refreshBooks() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshLoc() {
|
function refreshLoc() {
|
||||||
localize(currentLang);
|
$("[data-localize]")
|
||||||
|
.localize("main", { pathPrefix: "lang", language: currentLang })
|
||||||
|
.localize("books", { pathPrefix: "lang", language: currentLang });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to fill a data-localize attribute and update DOM
|
// Function to fill a data-localize attribute and update DOM
|
||||||
|
@ -30,17 +51,3 @@ function setLocalizeDataAttr(className, dataValue) {
|
||||||
.data("localize", dataValue)
|
.data("localize", dataValue)
|
||||||
.attr("data-localize", dataValue);
|
.attr("data-localize", dataValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function localize(lang) {
|
|
||||||
var overrideLang = "language:" + (lang ? lang : "");
|
|
||||||
$("[data-localize]")
|
|
||||||
.localize("main", {
|
|
||||||
pathPrefix: "lang",
|
|
||||||
overrideLang,
|
|
||||||
})
|
|
||||||
.localize("books", {
|
|
||||||
pathPrefix: "lang",
|
|
||||||
overrideLang,
|
|
||||||
});
|
|
||||||
currentLang = lang;
|
|
||||||
}
|
|
|
@ -107,8 +107,8 @@ http://keith-wood.name/localisation.html
|
||||||
statusCode: {
|
statusCode: {
|
||||||
404: function() {
|
404: function() {
|
||||||
console.log("Le fichier " + file + " n'existe pas.");
|
console.log("Le fichier " + file + " n'existe pas.");
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
if (window.location.protocol === "file:") {
|
if (window.location.protocol === "file:") {
|
||||||
ajaxOptions.error = function (xhr) {
|
ajaxOptions.error = function (xhr) {
|
||||||
|
@ -137,14 +137,6 @@ http://keith-wood.name/localisation.html
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
/*
|
|
||||||
This code is iterating over the elements in the DOM and calling a function to localize
|
|
||||||
them The first argument of this function is an element which we can use to determine
|
|
||||||
what type of element it is If it\'s an input or textarea then we call a different
|
|
||||||
function that will handle those two types of elements If it\'s an image then we call
|
|
||||||
another function that handles images If it\'s an optgroup then we call another one
|
|
||||||
for optgroups
|
|
||||||
*/
|
|
||||||
localizeElement = function (elem, key, value) {
|
localizeElement = function (elem, key, value) {
|
||||||
if (elem.is("input")) {
|
if (elem.is("input")) {
|
||||||
localizeInputElement(elem, key, value);
|
localizeInputElement(elem, key, value);
|
||||||
|
|
Loading…
Reference in a new issue