Update localization sync

This commit is contained in:
Elio Struyf
2023-08-20 14:07:50 +02:00
parent 4b2eef70cd
commit cbfb5a0ba2

View File

@@ -1,5 +1,6 @@
const fs = require('fs');
const path = require('path');
const glob = require('glob');
(async () => {
// Get all the files from the l10n directory
@@ -17,7 +18,13 @@ const path = require('path');
// Get the file content
const fileContent = fs.readFileSync(path.join(__dirname, `../l10n/${file}`), 'utf8');
const content = JSON.parse(fileContent);
let content = {};
try {
content = JSON.parse(fileContent);
} catch (e) {
// Ignore the error
}
// Loop through the EN keys
for (const key of enKeys) {
@@ -30,4 +37,34 @@ const path = require('path');
// Write the file
fs.writeFileSync(path.join(__dirname, `../l10n/${file}`), JSON.stringify(content, null, 2), 'utf8');
}
// Package JSON
const enPkgFile = fs.readFileSync(path.join(__dirname, '../package.nls.json'), 'utf8');
const enPkgContent = JSON.parse(enPkgFile);
const enPkgKeys = Object.keys(enPkgContent);
const pkgFiles = glob.sync(path.join(__dirname, '../package.nls.*.json'));
for (const file of pkgFiles) {
const fileContent = fs.readFileSync(file, 'utf8');
let content = {};
try {
content = JSON.parse(fileContent);
} catch (e) {
// Ignore the error
}
// Loop through the EN keys
for (const key of enPkgKeys) {
// If the key does not exist in the file, add it
if (!content[key]) {
content[key] = `🚧: ${enPkgContent[key]}`;
}
}
// Write the file
fs.writeFileSync(file, JSON.stringify(content, null, 2), 'utf8');
}
})();