check changed translations
This commit is contained in:
parent
5460848ea9
commit
02563dcf8b
|
@ -105,10 +105,20 @@ module.exports = function() {
|
||||||
}
|
}
|
||||||
const langPhraseCount = Object.keys(languageTranslations).length;
|
const langPhraseCount = Object.keys(languageTranslations).length;
|
||||||
const percentage = Math.round(langPhraseCount / totalPhraseCount * 100);
|
const percentage = Math.round(langPhraseCount / totalPhraseCount * 100);
|
||||||
const included = percentage >= PHRASE_COUNT_THRESHOLD_PERCENT;
|
let skip = percentage >= PHRASE_COUNT_THRESHOLD_PERCENT ? null : 'SKIP';
|
||||||
const action = included ? '\x1b[36mOK\x1b[0m' : '\x1b[35mSKIP\x1b[0m';
|
|
||||||
|
let languageJson = JSON.stringify(languageTranslations, null, 2);
|
||||||
|
if (!skip && fs.existsSync(`docs/translations/${lang}/${lang}.json`)) {
|
||||||
|
const oldJson = fs.readFileSync(`docs/translations/${lang}/${lang}.json`, { encoding: 'utf8' });
|
||||||
|
if (oldJson === languageJson) {
|
||||||
|
skip = 'NO CHANGES';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const action = skip ? `\x1b[35m${skip}\x1b[0m` : '\x1b[36mOK\x1b[0m';
|
||||||
|
|
||||||
console.log(`[${lang}] ${langPhraseCount} / ${totalPhraseCount} (${percentage}%) -> ${action}`);
|
console.log(`[${lang}] ${langPhraseCount} / ${totalPhraseCount} (${percentage}%) -> ${action}`);
|
||||||
if (included) {
|
if (!skip) {
|
||||||
langCount++;
|
langCount++;
|
||||||
for (const name of Object.keys(languageTranslations)) {
|
for (const name of Object.keys(languageTranslations)) {
|
||||||
let text = languageTranslations[name];
|
let text = languageTranslations[name];
|
||||||
|
@ -142,17 +152,18 @@ module.exports = function() {
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
if (text.indexOf('{}') >= 0 && enText.indexOf('{}') < 0) {
|
if (text.indexOf('{}') >= 0 && enText.indexOf('{}') < 0) {
|
||||||
const textHl = text.replace(/\{}/g, '\x1b[31m{}\x1b[0m');
|
const textHl = text.replace(/{}/g, '\x1b[31m{}\x1b[0m');
|
||||||
console.error(`[${lang}] \x1b[31mERROR:{}\x1b[0m ${name}: ${textHl}`);
|
console.error(`[${lang}] \x1b[31mERROR:{}\x1b[0m ${name}: ${textHl}`);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
if (enText.indexOf('{}') >= 0 && text.indexOf('{}') < 0) {
|
if (enText.indexOf('{}') >= 0 && text.indexOf('{}') < 0) {
|
||||||
const enTextHl = enText.replace(/\{}/g, '\x1b[31m{}\x1b[0m');
|
const enTextHl = enText.replace(/{}/g, '\x1b[31m{}\x1b[0m');
|
||||||
console.error(`[${lang}] \x1b[31mERROR:NO{}\x1b[0m ${name}: ${text} <--> ${enTextHl}`);
|
console.error(`[${lang}] \x1b[31mERROR:NO{}\x1b[0m ${name}: ${text} <--> ${enTextHl}`);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const languageJson = JSON.stringify(languageTranslations, null, 2);
|
|
||||||
|
languageJson = JSON.stringify(languageTranslations, null, 2);
|
||||||
|
|
||||||
const data = Buffer.from(languageJson);
|
const data = Buffer.from(languageJson);
|
||||||
const signature = await sign(data).catch(e => {
|
const signature = await sign(data).catch(e => {
|
||||||
|
|
Loading…
Reference in New Issue