1
0
Fork 0

Add a script to check missing translations.

This commit is contained in:
Kitteh 2021-04-24 17:20:39 +01:00
parent 75a927ed62
commit 3fba14de6c
3 changed files with 48 additions and 2 deletions

38
checkTranslations.mjs Normal file
View file

@ -0,0 +1,38 @@
import translation_en from './src/translations/en.js'
import translation_de from './src/translations/de.js'
import translation_ru from './src/translations/ru.js'
import translation_nl from './src/translations/nl.js'
import translation_fr from './src/translations/fr.js'
const langs = ["en", "de", "ru", "nl", "fr"];
const translations_dict = {
en: translation_en,
de: translation_de,
ru: translation_ru,
nl: translation_nl,
fr: translation_fr,
}
let en_keys = [...new Map(Object.entries(translations_dict.en)).keys()];
function arrayDiff(a, b) {
return {
missing: a.filter(x => !b.includes(x)),
extra: b.filter(x => !a.includes(x)),
};
}
for (let lang_num in langs) {
let lang = new Map(Object.entries(translations_dict[langs[lang_num]]));
if (lang == "en") continue;
let lang_keys = [...lang.keys()];
let di = arrayDiff(en_keys, [...lang.keys()])
console.log("Language:", langs[lang_num])
if (di.missing.length > 0) {
console.log("Missing: ", di.missing.join(", "))
}
if (di.extra.length > 0) {
console.log("Extra Keys (maybe deprecated, renamed or no longer exists, check git log): ", di.extra.join(", "))
}
}

View file

@ -19,4 +19,12 @@ WEBPACK_MODE=development BROWSER=google-chrome npx webpack serve
## Translating ## Translating
Make sure to keep the order of comments and tags in the translation files `src/translations` the same. Make sure to keep the order of comments and tags in the translation files `src/translations` the same.
When you want to PR an update, title it "Changed wording in..." or "Synced translations in de" or something along those lines. When you want to PR an update, title it "Changed wording in..." or "Synced translations in de" or something along those lines.
To get a list of what languages need what translations added, run `node ./checkTranslations.mjs`
Example:
```
Language: fr
Missing: unseal_input_btn, unseal_qr_btn
```
Means those two missing things need to be added to french.

View file

@ -7,7 +7,7 @@ import { MarginInline } from "../elements/MarginInline.js";
import i18next from 'i18next'; import i18next from 'i18next';
import QrScanner from 'qr-scanner'; import QrScanner from 'qr-scanner';
/* eslint-disable import/no-unresolved */ /* eslint-disable import/no-unresolved */
import qrScannerWorkerSource from '!!raw-loader!qr-scanner/qr-scanner-worker.min.js'; import qrScannerWorkerSource from '!!raw-loader!qr-scanner/qr-scanner-worker.min.js';
QrScanner.WORKER_PATH = URL.createObjectURL(new Blob([qrScannerWorkerSource])); QrScanner.WORKER_PATH = URL.createObjectURL(new Blob([qrScannerWorkerSource]));