2022-11-04 05:33:37 +01:00
|
|
|
/* eslint-disable no-console */
|
2020-09-12 13:19:33 +02:00
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
|
|
|
const prettier = require('prettier');
|
2020-09-14 04:01:02 +02:00
|
|
|
const messages = require('../build/messages.json');
|
2020-09-12 13:19:33 +02:00
|
|
|
|
2020-09-14 04:01:02 +02:00
|
|
|
const dest = path.resolve(__dirname, '../lang');
|
|
|
|
const files = fs.readdirSync(dest);
|
|
|
|
const keys = Object.keys(messages).sort();
|
2020-09-12 13:19:33 +02:00
|
|
|
|
|
|
|
files.forEach(file => {
|
|
|
|
const lang = require(`../lang/${file}`);
|
|
|
|
|
|
|
|
console.log(`Merging ${file}`);
|
|
|
|
|
|
|
|
const merged = keys.reduce((obj, key) => {
|
|
|
|
const message = lang[key];
|
|
|
|
|
2020-09-14 04:01:02 +02:00
|
|
|
obj[key] = message || messages[key].defaultMessage;
|
2020-09-12 13:19:33 +02:00
|
|
|
|
|
|
|
if (!message) {
|
2020-09-12 13:26:32 +02:00
|
|
|
console.log(`* Added key ${key}`);
|
2020-09-12 13:19:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
const json = prettier.format(JSON.stringify(merged), { parser: 'json' });
|
|
|
|
|
2020-09-14 04:01:02 +02:00
|
|
|
fs.writeFileSync(path.resolve(dest, file), json);
|
2020-09-12 13:19:33 +02:00
|
|
|
});
|