If l10n is set on page load, set OctoPrint.options.locale to its value
That way API requests will be made with the locale the page was requested in. See #1593
This commit is contained in:
parent
0d13c3b439
commit
b68ee4df98
2 changed files with 18 additions and 0 deletions
|
|
@ -865,3 +865,16 @@ var sizeObservable = function(observable) {
|
|||
}
|
||||
})
|
||||
};
|
||||
|
||||
var getQueryParameterByName = function(name, url) {
|
||||
// from http://stackoverflow.com/a/901144/2028598
|
||||
if (!url) {
|
||||
url = window.location.href;
|
||||
}
|
||||
name = name.replace(/[\[\]]/g, "\\$&");
|
||||
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
|
||||
results = regex.exec(url);
|
||||
if (!results) return null;
|
||||
if (!results[2]) return '';
|
||||
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,6 +13,11 @@ $(function() {
|
|||
OctoPrint.options.baseurl = BASEURL;
|
||||
OctoPrint.options.apikey = UI_API_KEY;
|
||||
|
||||
var l10n = getQueryParameterByName("l10n");
|
||||
if (l10n) {
|
||||
OctoPrint.options.locale = l10n;
|
||||
}
|
||||
|
||||
OctoPrint.socket.onMessage("connected", function(data) {
|
||||
var payload = data.data;
|
||||
OctoPrint.options.apikey = payload.apikey;
|
||||
|
|
|
|||
Loading…
Reference in a new issue