Add OctoPrint.options.locale and if set send X-Locale header on requests

See #1593
This commit is contained in:
Gina Häußge 2016-11-18 07:54:17 +01:00
parent 1a75dcd5ee
commit 0d13c3b439
2 changed files with 10 additions and 1 deletions

View file

@ -14,6 +14,10 @@
``OctoPrint.options.baseurl``
The base URL of the OctoPrint API
``OctoPrint.options.locale``
The locale to set in ``X-Locale`` headers on API requests. Useful for API
endpoints that might return localized content.
.. js:data:: OctoPrint.plugins
Registration of client library components provided by plugins.

View file

@ -46,7 +46,8 @@
OctoPrint.options = {
"baseurl": undefined,
"apikey": undefined
"apikey": undefined,
"locale": undefined
};
OctoPrint.plugins = {};
@ -65,6 +66,10 @@
var headers = $.extend({}, additional);
headers["X-Api-Key"] = OctoPrint.options.apikey;
if (OctoPrint.options.locale !== undefined) {
headers["X-Locale"] = OctoPrint.options.locale;
}
return headers;
};