import fs from 'fs'; // Lire le fichier JSON const jsonData = JSON.parse(fs.readFileSync('./compendium/wfrp4e-core.items.json', 'utf8')); const frJson = JSON.parse(fs.readFileSync('./fr.json', 'utf8')); // Chercher les termes en anglais (labels et titres courts) const englishTerms = new Set(); const termOccurrences = {}; // Parcourir les entrées jsonData.entries.forEach(entry => { // Vérifier le champ 'name' pour des patterns entre parenthèses if (entry.name && entry.name.includes('(') && entry.name.includes(')')) { const matches = entry.name.matchAll(/\(([^)]+)\)/g); for (const match of matches) { const parenthesisContent = match[1]; // Liste de termes français connus à exclure const frenchTerms = [ 'Mineure', 'Majeure', 'Accessible', 'Complexe', 'Difficile', 'Facile', 'Intermédiaire', 'Type', 'Domaine', 'Arme de jet', 'Arme de mêlée', 'Compétence avancée', 'Compétence de base' ]; // Détecter si c'est potentiellement de l'anglais // - Contient des mots anglais courants (et, the, or, of) // - Ne contient pas de caractères français (é, è, à, ô, etc.) const hasEnglishWords = /\b(and|the|or|of|to|in|a|is)\b/i.test(parenthesisContent); const hasNoFrenchChars = !/[àâäéèêëïîôùûüÿæœç]/i.test(parenthesisContent); const notInFrenchList = !frenchTerms.some(term => parenthesisContent.toLowerCase().includes(term.toLowerCase()) ); if ((hasEnglishWords || (hasNoFrenchChars && notInFrenchList)) && parenthesisContent.length > 2) { englishTerms.add(parenthesisContent); if (!termOccurrences[parenthesisContent]) { termOccurrences[parenthesisContent] = []; } termOccurrences[parenthesisContent].push({ id: entry.id, name: entry.name }); } } } }); // Afficher les résultats console.log('Termes anglais détectés dans les noms (entre parenthèses):'); console.log('==========================================================\n'); const sortedTerms = Array.from(englishTerms).sort(); sortedTerms.forEach(term => { console.log(`${term} (${termOccurrences[term].length} occurrence(s)):`); termOccurrences[term].slice(0, 3).forEach(occ => { console.log(` - ${occ.id}: ${occ.name}`); }); if (termOccurrences[term].length > 3) { console.log(` ... et ${termOccurrences[term].length - 3} autres`); } console.log(''); }); console.log(`\nTotal: ${englishTerms.size} termes anglais différents détectés`); // Chercher aussi dans d'autres champs console.log('\n\nAnalyse des autres champs potentiels...'); console.log('========================================\n'); // Chercher des labels courts en anglais dans tous les champs const fieldsToCheck = ['type', 'special', 'description']; const englishInFields = {}; jsonData.entries.slice(0, 20).forEach(entry => { Object.keys(entry).forEach(key => { if (typeof entry[key] === 'string' && entry[key].length < 50) { const value = entry[key]; // Détecter des mots anglais courants if (/\b(Rating|Target|Group|Feature|Type|Level|Rank)\b/.test(value)) { if (!englishInFields[key]) { englishInFields[key] = new Set(); } englishInFields[key].add(value); } } }); }); Object.keys(englishInFields).forEach(field => { console.log(`Champ '${field}':`); englishInFields[field].forEach(value => { console.log(` - "${value}"`); }); console.log(''); });