diff --git a/docs/jsclientlib/base.rst b/docs/jsclientlib/base.rst index e59cca69..65a56340 100644 --- a/docs/jsclientlib/base.rst +++ b/docs/jsclientlib/base.rst @@ -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. diff --git a/src/octoprint/static/js/app/client/base.js b/src/octoprint/static/js/app/client/base.js index eb159d0a..c0ea5292 100644 --- a/src/octoprint/static/js/app/client/base.js +++ b/src/octoprint/static/js/app/client/base.js @@ -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; };