From ee26f479a434d5cb307d575a5bcc49c789aa9877 Mon Sep 17 00:00:00 2001 From: KraXen72 Date: Tue, 15 Jul 2025 00:38:34 +0200 Subject: [PATCH] better missing translation checking --- __tests__/missingTranslations.js | 89 ++++++++++++++++++++++++++++++-- src/i18n_messages/en.json | 9 +++- 2 files changed, 93 insertions(+), 5 deletions(-) diff --git a/__tests__/missingTranslations.js b/__tests__/missingTranslations.js index ed62dbe2..bcbf6c8c 100644 --- a/__tests__/missingTranslations.js +++ b/__tests__/missingTranslations.js @@ -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.'); } }); diff --git a/src/i18n_messages/en.json b/src/i18n_messages/en.json index ac75fc7a..3720fde7 100644 --- a/src/i18n_messages/en.json +++ b/src/i18n_messages/en.json @@ -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" + } + } } \ No newline at end of file