Skip to content
Snippets Groups Projects
Commit b6e2c2f3 authored by Mathias Chouet's avatar Mathias Chouet Committed by mathias.chouet
Browse files

Add script to check missing translations of JaLHyd messages

parent 11057ede
No related branches found
No related tags found
1 merge request!82Resolve "Ajout de la fonctionnalité "Respect des critères""
'use strict';
const fs = require('fs');
// read and transform JaLHyd message file
const jalhydMessagesPath = "../jalhyd/src/util/message.ts";
let jm = fs.readFileSync(jalhydMessagesPath, "utf-8");
// extract enum block
jm = jm.replace(/export enum MessageCode \{([^{]+)\}[\s\S]+/m, (match, p1) => {
return p1;
});
// remove comments
jm = jm.replace(/\/\*[\s\S]*?\*\//gm, "");
jm = jm.replace(/\/\/.+/g, "");
// remove spaces
jm = jm.replace(/[ \t]+/g, "");
// remove line breaks
jm = jm.replace(/\n/g, "");
// split on ";"
const messages = jm.split(",");
// console.log(messages);
// read every language file
const localePath = "src/locale";
const localeDir = fs.readdirSync(localePath);
for (let i = 0; i < localeDir.length; i++) {
const localeFile = localeDir[i];
const res = localeFile.match(/^messages\.([a-z]{2})\.json$/);
if (res) {
const lang = res[1];
console.log("Loading translations for language [" + lang + "]");
const langFilePath = localePath + '/' + localeFile;
let translations = Object.keys(JSON.parse(fs.readFileSync(langFilePath, "utf-8")));
// console.log(translations);
// check against JaLHyd messages list
for (const mess of messages) {
if (! translations.includes(mess)) {
console.log(" missing message in [" + lang + "] translation: " + mess);
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment