Skip to content

Commit

Permalink
Merge pull request #219 from sbs20/staging
Browse files Browse the repository at this point in the history
Additional i18n; Fix A4/5
  • Loading branch information
sbs20 authored Apr 26, 2021
2 parents 25a65be + 0de7ff0 commit 8e56ba3
Show file tree
Hide file tree
Showing 17 changed files with 423 additions and 20 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ complicated installation.
* Filters: Autolevels, Threshold, Blur
* Configurable overrides for all defaults as well as filters and formats
* Multipage scanning (with collation for double sided scans)
* International translations: Czech, French, German, Italian, Mandarin, Spanish
(**help requested**)
* International translations: Czech, French, German, Italian, Mandarin, Russian,
Spanish; [Help requested](https://github.com/sbs20/scanservjs/issues/154)
* Light and dark mode
* Responsive design

Expand Down Expand Up @@ -69,7 +69,7 @@ module.exports = {
*/
afterConfig(config) {
// Set default preview resolution
config.previewResolution = 300;
config.previewResolution = 150;

// Add a custom print pipeline
config.pipelines.push({
Expand Down Expand Up @@ -122,4 +122,4 @@ and it's been a labour of love ever since.

## More about SANE

* http://www.sane-project.org/
* http://www.sane-project.org/
2 changes: 1 addition & 1 deletion server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scanservjs-server",
"version": "2.10.0",
"version": "2.11.0",
"description": "scanservjs is a simple web-based UI for SANE which allows you to share a scanner on a network without the need for drivers or complicated installation. scanserv does not do image conversion or manipulation (beyond the bare minimum necessary for the purposes of browser preview) or OCR.",
"scripts": {
"serve": "nodemon --exec 'vue-cli-service serve'",
Expand Down
4 changes: 2 additions & 2 deletions server/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class Config {

paperSizes: [
{ name: 'A3', dimensions: { x: 297, y: 420 } },
{ name: 'A4', dimensions: { x: 215, y: 297 } },
{ name: 'A5', dimensions: { x: 148, y: 215 } },
{ name: 'A4', dimensions: { x: 210, y: 297 } },
{ name: 'A5', dimensions: { x: 148, y: 210 } },
{ name: 'A6', dimensions: { x: 105, y: 148 } },
{ name: 'B3', dimensions: { x: 353, y: 500 } },
{ name: 'B4', dimensions: { x: 250, y: 353 } },
Expand Down
5 changes: 3 additions & 2 deletions webui/src/classes/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ const Constants = {
Version: process.env.VUE_APP_VERSION,

Locales: [
'cn',
'cz',
'cs',
'de',
'en',
'es',
'fr',
'it',
'ru',
'zh',
'test'
],

Expand Down
2 changes: 1 addition & 1 deletion webui/src/components/Files.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<tbody>
<tr v-for="file in files" v-bind:key="file.name">
<td><a @click="open(file)">{{ file.name }}</a></td>
<td class="file-date">{{ file.lastModified }}</td>
<td class="file-date">{{ $d(new Date(file.lastModified), 'long', $i18n.locale) }}</td>
<td>{{ file.sizeString }}</td>
<td><v-btn color="secondary" v-on:click="fileRemove(file)" icon><v-icon>mdi-delete</v-icon></v-btn></td>
</tr>
Expand Down
34 changes: 30 additions & 4 deletions webui/src/components/Scan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

<v-select v-if="'--source' in device.features"
:label="$t('scan.source')" v-model="request.params.source"
:items="device.features['--source']['options']"></v-select>
:items="sources" item-value="value" item-text="text"></v-select>

<v-select
:label="$t('scan.resolution')" v-model="request.params.resolution"
:items="device.features['--resolution']['options']"></v-select>

<v-select
:label="$t('scan.mode')" v-model="request.params.mode"
:items="device.features['--mode']['options']"></v-select>
:items="modes" item-value="value" item-text="text"></v-select>

<v-select v-if="'--disable-dynamic-lineart' in device.features"
:label="$t('scan.dynamic-lineart')" v-model="request.params.mode"
Expand Down Expand Up @@ -135,6 +135,10 @@ function round(n, dp) {
return Math.round(n * f) / f;
}
function sanitiseLocaleKey(s) {
return s.toLowerCase().replace(/\[/g, '(').replace(/\]/g, ')');
}
export default {
name: 'Scan',
components: {
Expand Down Expand Up @@ -195,6 +199,17 @@ export default {
});
},
modes() {
return this.device.features['--mode'].options.map(mode => {
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],
Expand All @@ -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
};
});
}
},
Expand Down Expand Up @@ -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) {
Expand Down
22 changes: 22 additions & 0 deletions webui/src/i18n.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
import Vue from 'vue';
import VueI18n from 'vue-i18n';
import Constants from './classes/constants';

Vue.use(VueI18n);

const dateTimeFormats = {};
for (const locale of Constants.Locales) {
dateTimeFormats[locale] = {
short: {
year: 'numeric',
month: 'short',
day: 'numeric'
},
long: {
year: 'numeric',
month: 'long',
day: 'numeric',
weekday: 'long',
hour: 'numeric',
minute: 'numeric',
hour12: false
}
};
}

function loadLocaleMessages () {
const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i);
const messages = {};
Expand All @@ -17,6 +38,7 @@ function loadLocaleMessages () {
}

export default new VueI18n({
dateTimeFormats,
locale: process.env.VUE_APP_I18N_LOCALE || 'en',
fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en',
messages: loadLocaleMessages()
Expand Down
39 changes: 34 additions & 5 deletions webui/src/locales/cz.json → webui/src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
},

"batch-dialog": {
"btn-cancel": "Zrušení",
"btn-finish": "Dokončit",
"btn-rescan": "Znovu oskenovat stránku",
"btn-rescan": "Znovu oskenovat",
"btn-next": "Další"
},

Expand All @@ -31,10 +32,38 @@

"filter": {
"auto-level": "Automatické zarovnání",
"threshold": "Prahová hodnota barev",
"threshold": "Práh",
"blur": "Rozmazané"
},

"mode": {
"color": "Barevný",
"halftone": "Halftone",
"gray": "Černobílý",
"lineart": "Perokresba",

"24bitcolor":"@:mode.color",
"black & white": "@:mode.lineart",
"gray(error diffusion)": "@:mode.halftone",
"true gray": "@:mode.gray",
"24bit color(fast)": "@:mode.color"
},

"source": {
"flatbed": "Skenovací deska",
"adf": "ADF",
"auto": "Auto",
"left-aligned": "Left Aligned",
"centrally-aligned": "Centrally Aligned",
"duplex": "Duplex",

"automatic document feeder": "@:source.adf",
"automatic document feeder(left aligned)": "@:source.adf (@:source.left-aligned)",
"automatic document feeder(left aligned,duplex)": "@:source.adf (@:source.left-aligned, @:source.duplex)",
"automatic document feeder(centrally aligned)": "@:source.adf (@:source.centrally-aligned)",
"automatic document feeder(centrally aligned,duplex)": "@:source.adf (@:source.centrally-aligned, @:source.duplex)"
},

"pipeline": {
"high-quality": "Vysoká kvalita",
"medium-quality": "Střední kvalita",
Expand All @@ -61,8 +90,8 @@
"batch:auto-collate-reverse": "Automatický (Obrátit 1, 3... 2, 4)",
"filters": "Filtry",
"format": "Formát",
"btn-preview": "Načíst náhled",
"btn-clear": "Vymazat",
"btn-preview": "Náhled",
"btn-clear": "Smazat",
"btn-scan": "Skenovat",
"btn-reset": "Resetovat",
"top": "Nahoře",
Expand All @@ -85,7 +114,7 @@
"locale": "Lokalizace",
"locale:description": "Vyberte vaši lokalizaci",
"theme": "Motiv",
"theme:description": "Motiv. Pokud použijete systémový motiv a ten se změní, budete potřebovat přenačíst aplikaci.",
"theme:description": "Motiv. Pokud použijete systémový motiv a ten se změní, budete potřebovat aktualizovat stránku s aplikací.",
"theme:system": "Podle systému",
"theme:light": "Světlý",
"theme:dark": "Tmavý"
Expand Down
29 changes: 29 additions & 0 deletions webui/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},

"batch-dialog": {
"btn-cancel": "Stornieren",
"btn-finish": "Fertig",
"btn-rescan": "Seite erneut scannen",
"btn-next": "Nächste Seite scannen"
Expand All @@ -35,6 +36,34 @@
"blur": "Weichzeichner"
},

"mode": {
"color": "Colour",
"halftone": "Halftone",
"gray": "Grey",
"lineart": "Lineart",

"24bitcolor":"@:mode.color",
"black & white": "@:mode.lineart",
"gray(error diffusion)": "@:mode.halftone",
"true gray": "@:mode.gray",
"24bit color(fast)": "@:mode.color"
},

"source": {
"flatbed": "Flatbed",
"adf": "Automatic Document Feeder",
"auto": "Auto",
"left-aligned": "Left Aligned",
"centrally-aligned": "Centrally Aligned",
"duplex": "Duplex",

"automatic document feeder": "@:source.adf",
"automatic document feeder(left aligned)": "@:source.adf (@:source.left-aligned)",
"automatic document feeder(left aligned,duplex)": "@:source.adf (@:source.left-aligned, @:source.duplex)",
"automatic document feeder(centrally aligned)": "@:source.adf (@:source.centrally-aligned)",
"automatic document feeder(centrally aligned,duplex)": "@:source.adf (@:source.centrally-aligned, @:source.duplex)"
},

"pipeline": {
"high-quality": "Hohe Qualität",
"medium-quality": "Mittlere Qualität",
Expand Down
29 changes: 29 additions & 0 deletions webui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},

"batch-dialog": {
"btn-cancel": "Cancel",
"btn-finish": "Finish",
"btn-rescan": "Rescan page",
"btn-next": "Next"
Expand All @@ -35,6 +36,34 @@
"blur": "Blur"
},

"mode": {
"color": "Colour",
"halftone": "Halftone",
"gray": "Grey",
"lineart": "Lineart",

"24bitcolor":"@:mode.color",
"black & white": "@:mode.lineart",
"gray(error diffusion)": "@:mode.halftone",
"true gray": "@:mode.gray",
"24bit color(fast)": "@:mode.color"
},

"source": {
"flatbed": "Flatbed",
"adf": "ADF",
"auto": "Auto",
"left-aligned": "Left Aligned",
"centrally-aligned": "Centrally Aligned",
"duplex": "Duplex",

"automatic document feeder": "@:source.adf",
"automatic document feeder(left aligned)": "@:source.adf (@:source.left-aligned)",
"automatic document feeder(left aligned,duplex)": "@:source.adf (@:source.left-aligned, @:source.duplex)",
"automatic document feeder(centrally aligned)": "@:source.adf (@:source.centrally-aligned)",
"automatic document feeder(centrally aligned,duplex)": "@:source.adf (@:source.centrally-aligned, @:source.duplex)"
},

"pipeline": {
"high-quality": "High quality",
"medium-quality": "Medium quality",
Expand Down
29 changes: 29 additions & 0 deletions webui/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},

"batch-dialog": {
"btn-cancel": "Cancelar",
"btn-finish": "Terminar",
"btn-rescan": "Reescanear página",
"btn-next": "Siguiente"
Expand All @@ -35,6 +36,34 @@
"blur": "Difuminar"
},

"mode": {
"color": "Colour",
"halftone": "Halftone",
"gray": "Grey",
"lineart": "Lineart",

"24bitcolor":"@:mode.color",
"black & white": "@:mode.lineart",
"gray(error diffusion)": "@:mode.halftone",
"true gray": "@:mode.gray",
"24bit color(fast)": "@:mode.color"
},

"source": {
"flatbed": "Flatbed",
"adf": "Automatic Document Feeder",
"auto": "Auto",
"left-aligned": "Left Aligned",
"centrally-aligned": "Centrally Aligned",
"duplex": "Duplex",

"automatic document feeder": "@:source.adf",
"automatic document feeder(left aligned)": "@:source.adf (@:source.left-aligned)",
"automatic document feeder(left aligned,duplex)": "@:source.adf (@:source.left-aligned, @:source.duplex)",
"automatic document feeder(centrally aligned)": "@:source.adf (@:source.centrally-aligned)",
"automatic document feeder(centrally aligned,duplex)": "@:source.adf (@:source.centrally-aligned, @:source.duplex)"
},

"pipeline": {
"high-quality": "Calidad alta",
"medium-quality": "Calidad media",
Expand Down
Loading

0 comments on commit 8e56ba3

Please sign in to comment.