8000 Utility: find missing translations by sbs20 · Pull Request #559 · sbs20/scanservjs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Utility: find missing translations #559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,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: Arabic, Czech, Dutch, French, German, Italian, Mandarin,
Polish, Portuguese (PT & BR), Russian, Spanish, Turkish;
* International translations: Arabic, Czech, Dutch, French, German, Italian,
Mandarin, Polish, Portuguese (PT & BR), Russian, Slovak, Spanish, Turkish;
[Help requested](https://github.com/sbs20/scanservjs/issues/154)
* Light and dark mode
* Responsive design
Expand Down
6 changes: 6 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ Alternatively, create a local release package
npm run release
```

## Find missing translations

```
npm run missing-translations
```

## Updating node dependencies

* `npm audit fix` or `npm update`. This won't remove old packages; to do so,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"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.",
"scripts": {
"clean": "rm -rf ./dist",
"missing-translations": "cd packages/client && npm run missing-translations",
"version": "npm i && cd packages/client && npm --allow-same-version --no-git-tag-version version $npm_package_version && cd ../server && npm --allow-same-version --no-git-tag-version version $npm_package_version",
"install": "cd packages/client && npm i --loglevel=error && cd ../server && npm i --loglevel=error",
"lint": "cd packages/server && npm run lint",
Expand Down
77 changes: 77 additions & 0 deletions packages/client/missing-translations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const fs = require('fs');

const EXCLUDED_KEY = ['locales'];
const BASE = 'en.json';

function missingKeys(o1, o2) {
return Object.keys(o1)
.filter(k => !EXCLUDED_KEY.some(ex => ex === k))
.flatMap(k => {
return (!(k in o2))
? [k]
: typeof o2[k] === 'object'
? missingKeys(o1[k], o2[k]).map(s => `${k}.${s}`)
: [];
});
}

const locales = new class Locales {
constructor(path) {
this.path = path || 'src/locales';
}

/**
* @returns {Promise.<string[]>}
*/
async list() {
return await new Promise((resolve, reject) => {
fs.readdir(this.path, (err, list) => {
if (err) {
reject(err);
}
resolve(list);
});
});
}

/**
* @returns {Promise.<object[]>}
*/
async all() {
if (this._all === undefined) {
this._all = (await this.list())
.map(s => ({
key: s,
data: require(`./${this.path}/${s}`)
}));
}
return this._all;
}

/**
* @returns {Promise.<object>}
*/
async base() {
return (await this.all()).filter(l => l.key === BASE)[0];
}

/**
* @returns {Promise.<object[]>}
*/
async children() {
return (await this.all()).filter(l => l.key !== BASE);
}
}

async function main() {
const en = await locales.base();
const children = await locales.children();
const report = children
.map(child => ({
key: child.key,
missing: missingKeys(en.data, child.data)
}));
console.log(JSON.stringify(report));
}

main();
1 change: 1 addition & 0 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"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.",
"author": "Sam Strachan",
"scripts": {
"missing-translations": "node missing-translations.js",
"serve": "nodemon --exec 'vue-cli-service serve'",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
Expand Down
6 changes: 5 additions & 1 deletion packages/client/src/locales/test.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"global": {
"application-name": "##APPNAME"
"application-name": "##APPNAME",
"no-data-text": "##NODATA"
},

"about": {
"main": "##ABOUT.MAIN",
"issue": "##ABOUT.ISSUE",
"api": "##SWAGGER API:",
"system-info": "###ABOUT.SYSTEM-INFO"
},

Expand Down Expand Up @@ -45,8 +47,10 @@
"size": "##SIZE",
"items-per-page": "##ITEMS-PER-PAGE",
"items-per-page-all": "##ALL",
"message:action": "##RUN {0} ON {1}",
"message:deleted": "##MESSAGE:DELETED {0}",
"message:renamed": "##FILE-RENAMED",
"button:action-selected": "##RUN-ACTION",
"button:delete-selected": "##DELETE-SELECTED",
"dialog:rename": "##RENAME",
"dialog:rename-cancel": "##CANCEL",
Expand Down
5 changes: 1 addition & 4 deletions packages/client/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@
"dialog:rename": "更改文件名称",
"dialog:rename-cancel": "取消",
"dialog:rename-save": "保存",
"actions": "操作",
"thumbnail-show": "Show thumbnails",
"thumbnail-size": "Thumbnail size"
"actions": "操作"
},

"navigation": {
Expand Down Expand Up @@ -167,7 +165,6 @@
"theme:dark": "深色",
"color": "颜色",
"color:description": "切换顶部应用栏的颜色。",
"show-files-after-scan:description": "Show files after scan completes",
"devices": "设备和存储",
"reset:description": "清空扫描仪列表并强制重新加载设备",
"reset": "重置",
Expand Down
0