From 73655da12b654b55705bbbe8021a1f0ac0721bc7 Mon Sep 17 00:00:00 2001 From: sbs20 Date: Mon, 26 Apr 2021 11:11:25 +0100 Subject: [PATCH] Translatable modes and sources #209 --- webui/src/components/Scan.vue | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/webui/src/components/Scan.vue b/webui/src/components/Scan.vue index 3d0860d0..aaa5fa3a 100644 --- a/webui/src/components/Scan.vue +++ b/webui/src/components/Scan.vue @@ -10,7 +10,7 @@ + :items="sources" item-value="value" item-text="text"> + :items="modes" item-value="value" item-text="text"> { + const key = `mode.${sanitiseLocaleKey(mode)}`; + let translation = this.$t(key); + return { + text: translation === key ? mode : translation, + value: mode + }; + }); + }, + paperSizes() { const deviceSize = { x: this.device.features['-x'].limits[1], @@ -219,6 +234,17 @@ export default { value: p }; }); + }, + + sources() { + return this.device.features['--source'].options.map(source => { + const key = `source.${sanitiseLocaleKey(source)}`; + let translation = this.$t(key); + return { + text: translation === key ? source : translation, + value: source + }; + }); } }, @@ -400,9 +426,9 @@ export default { return this._fetch(url).then(context => { window.clearTimeout(timer); - this.context = context; - if (context.devices.length > 0) { + if (context.devices && context.devices.length > 0) { + this.context = context; this.device = context.devices[0]; this.request = this.buildRequest(); for (let test of context.diagnostics) {