Merge branch 'develop' into feature/bookdisplay
This commit is contained in:
commit
965e278ba6
3 changed files with 32 additions and 30 deletions
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
@ -8,4 +8,5 @@
|
||||||
"url": "/./.vscode/spells-schemas.json"
|
"url": "/./.vscode/spells-schemas.json"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"stenography.apiKey": "caac2b35-1682-4741-a409-d687f69d9767",
|
||||||
}
|
}
|
|
@ -1,35 +1,16 @@
|
||||||
// In a browser where the language is set to French
|
// In a browser where the language is set to French
|
||||||
$("[data-localize]")
|
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() {
|
||||||
$("[data-localize]")
|
localize("fr");
|
||||||
.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() {
|
||||||
$("[data-localize]")
|
localize("en");
|
||||||
.localize("main", {
|
|
||||||
pathPrefix: "lang",
|
|
||||||
language: "en",
|
|
||||||
})
|
|
||||||
.localize("books", {
|
|
||||||
pathPrefix: "lang",
|
|
||||||
language: "en",
|
|
||||||
});
|
|
||||||
currentLang = "en";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshBooks() {
|
function refreshBooks() {
|
||||||
|
@ -40,9 +21,7 @@ function refreshBooks() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshLoc() {
|
function refreshLoc() {
|
||||||
$("[data-localize]")
|
localize(currentLang);
|
||||||
.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
|
||||||
|
@ -51,3 +30,17 @@ 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;
|
||||||
|
}
|
|
@ -105,10 +105,10 @@ http://keith-wood.name/localisation.html
|
||||||
success: successFunc,
|
success: successFunc,
|
||||||
error: errorFunc,
|
error: errorFunc,
|
||||||
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,6 +137,14 @@ 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);
|
||||||
|
@ -243,4 +251,4 @@ http://keith-wood.name/localisation.html
|
||||||
};
|
};
|
||||||
$.fn.localize = $.localize;
|
$.fn.localize = $.localize;
|
||||||
return ($.localize.data = {});
|
return ($.localize.data = {});
|
||||||
})(jQuery);
|
})(jQuery);
|
Loading…
Reference in a new issue