Skip to content

Commit

Permalink
Pipeline translations #151
Browse files Browse the repository at this point in the history
  • Loading branch information
sbs20 committed Mar 27, 2021
1 parent 6548c94 commit 067c0bc
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 14 deletions.
1 change: 1 addition & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ cd server && gulp release

## References
* [Run server with webpack](https://dennisreimann.de/articles/vue-cli-serve-express.html)
* [i18n](https://www.codeandweb.com/babeledit/tutorials/how-to-translate-your-vue-app-with-vue-i18n)

## Docker

Expand Down
24 changes: 12 additions & 12 deletions server/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,23 @@ class Config {
pipelines: [
{
extension: 'jpg',
description: 'JPG | High quality',
description: 'JPG | $$high-quality',
commands: [
'convert @- -quality 92 scan-%04d.jpg',
'ls scan-*.*'
]
},
{
extension: 'jpg',
description: 'JPG | Medium quality',
description: 'JPG | $$medium-quality',
commands: [
'convert @- -quality 75 scan-%04d.jpg',
'ls scan-*.*'
]
},
{
extension: 'jpg',
description: 'JPG | Low quality',
description: 'JPG | $$low-quality',
commands: [
'convert @- -quality 50 scan-%04d.jpg',
'ls scan-*.*'
Expand All @@ -104,31 +104,31 @@ class Config {
},
{
extension: 'tif',
description: 'TIF | Uncompressed',
description: 'TIF | $$uncompressed',
commands: [
'convert @- scan-0000.tif',
'ls scan-*.*'
]
},
{
extension: 'tif',
description: 'TIF | LZW compression',
description: 'TIF | $$lzw-compressed',
commands: [
'convert @- -compress lzw scan-0000.tif',
'ls scan-*.*'
]
},
{
extension: 'pdf',
description: 'PDF (TIF | Uncompressed)',
description: 'PDF (TIF | $$uncompressed)',
commands: [
'convert @- scan-0000.pdf',
'ls scan-*.*'
]
},
{
extension: 'pdf',
description: 'PDF (TIF | LZW Compression)',
description: 'PDF (TIF | $$lzw-compressed)',
commands: [
'convert @- -compress lzw tmp-%04d.tif && ls tmp-*.tif',
'convert @- scan-0000.pdf',
Expand All @@ -137,7 +137,7 @@ class Config {
},
{
extension: 'pdf',
description: 'PDF (JPG | High quality)',
description: 'PDF (JPG | $$high-quality)',
commands: [
'convert @- -quality 92 tmp-%04d.jpg && ls tmp-*.jpg',
'convert @- scan-0000.pdf',
Expand All @@ -146,7 +146,7 @@ class Config {
},
{
extension: 'pdf',
description: 'PDF (JPG | Medium quality)',
description: 'PDF (JPG | $$medium-quality)',
commands: [
'convert @- -quality 75 tmp-%04d.jpg && ls tmp-*.jpg',
'convert @- scan-0000.pdf',
Expand All @@ -155,7 +155,7 @@ class Config {
},
{
extension: 'pdf',
description: 'PDF (JPG | Low quality)',
description: 'PDF (JPG | $$low-quality)',
commands: [
'convert @- -quality 50 tmp-%04d.jpg && ls tmp-*.jpg',
'convert @- scan-0000.pdf',
Expand All @@ -168,7 +168,7 @@ class Config {
this.pipelines = this.pipelines.concat([
{
extension: 'pdf',
description: 'OCR | PDF (JPG | High quality)',
description: 'OCR | PDF (JPG | $$high-quality)',
commands: [
'convert @- -quality 92 tmp-%d.jpg && ls tmp-*.jpg',
`${this.tesseract} -l ${this.ocrLanguage} -c stream_filelist=true - - pdf > scan-0001.pdf`,
Expand All @@ -177,7 +177,7 @@ class Config {
},
{
extension: 'txt',
description: 'OCR | Text file',
description: 'OCR | $$text-file',
commands: [
`${this.tesseract} -l ${this.ocrLanguage} -c stream_filelist=true - - txt > scan-0001.txt`,
'ls scan-*.*'
Expand Down
21 changes: 19 additions & 2 deletions webui/src/components/Scan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@
multiple />

<v-select
:label="$t('scan.format')" v-model="request.pipeline"
:items="context.pipelines"></v-select>
:label="$t('scan.format')"
v-model="request.pipeline"
:items="context.pipelines"
item-text="text"
item-value="value"></v-select>

<div class="d-flex flex-row-reverse flex-wrap">
<v-btn color="green" @click="createPreview" class="ml-1 mb-1">{{ $t('scan.btn-preview') }} <v-icon class="ml-2">mdi-magnify</v-icon></v-btn>
Expand Down Expand Up @@ -316,6 +319,20 @@ export default {
value: f
};
});
context.pipelines = context.pipelines.map(p => {
const variables = (p.match(/\$\$[a-z-]+/ig) || []).map(s => s.substr(2));
let text = p;
variables.forEach(v => {
text = text.replaceAll(`$$${v}`, this.$t(`pipeline.${v}`));
});
return {
text: text,
value: p
};
});
this.context = context;
if (context.devices.length > 0) {
Expand Down
9 changes: 9 additions & 0 deletions webui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
"version": "Version"
},

"pipeline": {
"high-quality": "High quality",
"medium-quality": "Medium quality",
"low-quality": "Low quality",
"uncompressed": "Uncompressed",
"lzw-compressed": "LZW Compressed",
"text-file": "Text file"
},

"scan": {
"device": "Device",
"source": "Source",
Expand Down
9 changes: 9 additions & 0 deletions webui/src/locales/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
"version": "##VERSION"
},

"pipeline": {
"high-quality": "##HIGH-QUALITY",
"medium-quality": "##MEDIUM-QUALITY",
"low-quality": "##LOW-QUALITY",
"uncompressed": "##UNCOMPRESSED",
"lzw-compressed": "##LZW-COMPRESSED",
"text-file": "##TEXT-FILE"
},

"scan": {
"device": "##SCAN.DEVICE",
"source": "##SCAN.SOURCE",
Expand Down

0 comments on commit 067c0bc

Please sign in to comment.