2019-08-24 04:43:12 +00:00
|
|
|
import { en } from './src/translations/en';
|
2019-08-26 21:42:53 +00:00
|
|
|
import { eo } from './src/translations/eo';
|
2019-08-24 04:43:12 +00:00
|
|
|
import { es } from './src/translations/es';
|
|
|
|
import { de } from './src/translations/de';
|
2020-01-30 01:35:41 +00:00
|
|
|
import { fa } from './src/translations/fa';
|
2019-08-24 04:43:12 +00:00
|
|
|
import { zh } from './src/translations/zh';
|
|
|
|
import { fr } from './src/translations/fr';
|
|
|
|
import { sv } from './src/translations/sv';
|
|
|
|
import { ru } from './src/translations/ru';
|
2019-08-29 18:20:21 +00:00
|
|
|
import { nl } from './src/translations/nl';
|
2019-10-21 07:02:20 +00:00
|
|
|
import { it } from './src/translations/it';
|
2020-01-26 17:37:07 +00:00
|
|
|
import { fi } from './src/translations/fi';
|
2020-01-26 20:20:25 +00:00
|
|
|
import { ca } from './src/translations/ca';
|
2020-02-05 18:12:13 +00:00
|
|
|
import { pt_BR } from './src/translations/pt_br';
|
2020-01-19 21:23:04 +00:00
|
|
|
import fs from 'fs';
|
2019-08-24 04:43:12 +00:00
|
|
|
|
2020-01-26 19:31:34 +00:00
|
|
|
const files = [
|
2020-01-26 21:38:08 +00:00
|
|
|
{ t: ca, n: 'ca' },
|
2020-01-26 19:31:34 +00:00
|
|
|
{ t: de, n: 'de' },
|
2020-01-30 01:35:41 +00:00
|
|
|
{ t: fa, n: 'fa' },
|
2020-01-26 19:31:34 +00:00
|
|
|
{ t: eo, n: 'eo' },
|
|
|
|
{ t: es, n: 'es' },
|
|
|
|
{ t: fi, n: 'fi' },
|
|
|
|
{ t: fr, n: 'fr' },
|
|
|
|
{ t: it, n: 'it' },
|
|
|
|
{ t: nl, n: 'nl' },
|
2020-02-05 18:12:13 +00:00
|
|
|
{ t: pt_BR, n: 'pt-br' },
|
2020-01-26 19:31:34 +00:00
|
|
|
{ t: ru, n: 'ru' },
|
|
|
|
{ t: sv, n: 'sv' },
|
|
|
|
{ t: zh, n: 'zh' },
|
|
|
|
];
|
|
|
|
const masterKeys = Object.keys(en.translation);
|
|
|
|
|
2020-01-26 18:53:57 +00:00
|
|
|
const readmePath = '../README.md';
|
2020-01-19 21:23:04 +00:00
|
|
|
|
2020-01-26 18:53:57 +00:00
|
|
|
const open = '<!-- translations -->';
|
|
|
|
const close = '<!-- translationsstop -->';
|
2020-01-19 21:23:04 +00:00
|
|
|
|
2020-01-26 18:53:57 +00:00
|
|
|
const readmeTxt = fs.readFileSync(readmePath, { encoding: 'utf8' });
|
2020-01-19 21:23:04 +00:00
|
|
|
|
2020-01-26 18:53:57 +00:00
|
|
|
const before = readmeTxt.split(open)[0];
|
|
|
|
const after = readmeTxt.split(close)[1];
|
2020-01-19 21:23:04 +00:00
|
|
|
|
2020-01-26 20:49:47 +00:00
|
|
|
function difference(a: Array<string>, b: Array<string>): Array<string> {
|
|
|
|
return a.filter(x => !b.includes(x));
|
|
|
|
}
|
2020-01-26 19:31:34 +00:00
|
|
|
|
2020-01-26 21:38:08 +00:00
|
|
|
const report =
|
2020-01-26 19:31:34 +00:00
|
|
|
'lang | done | missing\n' +
|
|
|
|
'---- | ---- | -------\n' +
|
2020-01-26 21:38:08 +00:00
|
|
|
files
|
|
|
|
.map(file => {
|
|
|
|
const keys = Object.keys(file.t.translation);
|
|
|
|
const pct: number = (keys.length / masterKeys.length) * 100;
|
|
|
|
const missing = difference(masterKeys, keys);
|
|
|
|
return `${file.n} | ${pct.toFixed(0)}% | ${missing}`;
|
|
|
|
})
|
|
|
|
.join('\n');
|
2020-01-19 21:23:04 +00:00
|
|
|
|
2020-01-26 18:53:57 +00:00
|
|
|
const alteredReadmeTxt = `${before}${open}\n\n${report}\n${close}${after}`;
|
2019-08-24 04:43:12 +00:00
|
|
|
|
2020-01-19 21:23:04 +00:00
|
|
|
fs.writeFileSync(readmePath, alteredReadmeTxt);
|