better missing translation checking

This commit is contained in:
KraXen72
2025-07-15 00:38:34 +02:00
parent 97cfe9973b
commit ee26f479a4
2 changed files with 93 additions and 5 deletions
+85 -4
View File
@@ -1,16 +1,97 @@
const { exec } = require('child_process');
const fs = require('fs');
const path = require('path');
exec('tsc --noEmit', (error, stdout, stderr) => {
console.log('TRANSLATION ANALYSIS');
console.log('=' + '='.repeat(50));
// First, run the translation analysis
try {
// Read settings.json to get language configuration
const settingsPath = path.join(__dirname, '..', 'minibits.inlang', 'settings.json');
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
const defaultLanguage = settings.sourceLanguageTag;
const allLanguages = settings.languageTags;
console.log(`Default language: ${defaultLanguage}`);
console.log(`All languages: ${allLanguages.join(', ')}`);
console.log('=' + '='.repeat(50));
// Load all translation files
const translations = {};
const i18nMessagesPath = path.join(__dirname, '..', 'src', 'i18n_messages');
allLanguages.forEach(lang => {
const filePath = path.join(i18nMessagesPath, `${lang}.json`);
if (fs.existsSync(filePath)) {
try {
translations[lang] = JSON.parse(fs.readFileSync(filePath, 'utf8'));
} catch (error) {
console.error(`Error reading ${lang}.json:`, error.message);
translations[lang] = {};
}
} else {
console.warn(`Translation file not found: ${lang}.json`);
translations[lang] = {};
}
});
// Get keys from default language
const defaultKeys = Object.keys(translations[defaultLanguage] || {});
const totalKeys = defaultKeys.length;
console.log(`Total keys in default language (${defaultLanguage}): ${totalKeys}`);
console.log('=' + '='.repeat(50));
// Check each language
allLanguages.forEach(lang => {
if (lang === defaultLanguage) {
console.log(`\n${lang.toUpperCase()} (default language)`);
console.log(`✅ 100% translated (${totalKeys}/${totalKeys} keys)`);
return;
}
const currentKeys = Object.keys(translations[lang] || {});
const currentTotal = currentKeys.length;
const missingKeys = defaultKeys.filter(key => !translations[lang].hasOwnProperty(key));
const percentageTranslated = totalKeys > 0 ? Math.round((currentTotal / totalKeys) * 100) : 0;
console.log(`\n${lang.toUpperCase()}`);
console.log(`📊 ${percentageTranslated}% translated (${currentTotal}/${totalKeys} keys)`);
if (missingKeys.length > 0) {
console.log(`❌ Missing ${missingKeys.length} keys:`);
missingKeys.forEach(key => {
console.log(` - ${key}`);
});
} else {
console.log(`✅ No missing keys!`);
}
});
console.log('\n' + '=' + '='.repeat(50));
console.log('✅ Translation analysis complete!');
} catch (translationError) {
console.error('❌ Error during translation analysis:', translationError.message);
}
console.log('\n' + '=' + '='.repeat(50));
console.log('TYPESCRIPT ERROR CHECK');
console.log('=' + '='.repeat(50));
// Now run the TypeScript error checking
exec('tsc --noEmit', (error, stdout) => {
if (error) {
const output = stdout;
const filteredErrors = output.split('\n').filter(line => line.includes('TxKeyPath'));
if (filteredErrors.length > 0) {
console.log('❌ TypeScript errors containing TxKeyPath found:');
console.log(filteredErrors.join('\n'));
} else {
console.log('No errors containing TxKeyPath found.');
console.log('✅ No TypeScript errors containing TxKeyPath found.');
}
// process.exit(1); // Ensure the script returns an error code if there were any errors
} else {
console.log('No TypeScript errors found.');
console.log('✅ No TypeScript errors found.');
}
});
+8 -1
View File
@@ -684,5 +684,12 @@
"welcomeScreen_page3_final": "Now, let's move some ecash!",
"welcomeScreen_page3_go": "Let's go!",
"welcomeScreen_page3_heading": "Don't forget",
"welcomeScreen_page3_intro": "Both the Cashu protocol and the Minibits wallet are experimental. By using them, you accept known and unknown risks."
"welcomeScreen_page3_intro": "Both the Cashu protocol and the Minibits wallet are experimental. By using them, you accept known and unknown risks.",
"emptyStateComponent": {
"generic": {
"heading": "No data available",
"content": "There is nothing to display at the moment.",
"button": "Try again"
}
}
}