lemmy/ui/translation_report.ts

36 lines
1017 B
TypeScript
Raw Normal View History

import { en } from './src/translations/en';
2019-08-26 21:42:53 +00:00
import { eo } from './src/translations/eo';
import { es } from './src/translations/es';
import { de } from './src/translations/de';
import { zh } from './src/translations/zh';
import { fr } from './src/translations/fr';
import { sv } from './src/translations/sv';
import { ru } from './src/translations/ru';
let files = [
{t: de, n: 'de'},
2019-08-25 00:58:55 +00:00
{t: es, n: 'es'},
2019-08-26 21:42:53 +00:00
{t: eo, n: 'eo'},
{t: fr, n: 'fr'},
{t: ru, n: 'ru'},
2019-08-25 00:58:55 +00:00
{t: sv, n: 'sv'},
{t: zh, n: 'zh'},
];
let masterKeys = Object.keys(en.translation);
2019-08-25 00:58:55 +00:00
let report = 'lang | done | missing\n';
report += '--- | --- | ---\n';
for (let file of files) {
let keys = Object.keys(file.t.translation);
let pct: number = (keys.length / masterKeys.length * 100);
let missing = difference(masterKeys, keys);
2019-08-25 00:58:55 +00:00
report += `${file.n} | ${pct.toFixed(0)}% | ${missing} \n`;
}
console.log(report);
function difference(a: Array<string>, b: Array<string>): Array<string> {
return a.filter(x => !b.includes(x));
}