- Add intelligent content-game compatibility system with visual badges - Fix Adventure Reader to work with Dragon's Pearl content structure - Implement multi-column games grid for faster navigation - Add pronunciation display for Chinese vocabulary and sentences - Fix navigation breadcrumb to show proper hierarchy (Home > Levels > Content) - Add back buttons to all navigation pages - Improve JSONContentLoader to preserve story structure - Add comprehensive debugging and diagnostic tools 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
321 lines
14 KiB
JavaScript
321 lines
14 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// Test de conversion: english-exemple-commented.js → JSON Ultra-Modulaire
|
|
console.log('🚀 Conversion english-exemple-commented.js → JSON Ultra-Modulaire');
|
|
console.log('================================================================');
|
|
|
|
// Simuler l'environnement browser
|
|
global.window = {
|
|
ContentModules: {}
|
|
};
|
|
|
|
// Charger le module JS
|
|
require('./js/content/english-exemple-commented.js');
|
|
|
|
// Récupérer le module depuis l'objet global
|
|
const englishModule = global.window?.ContentModules?.EnglishExempleCommented;
|
|
|
|
if (!englishModule) {
|
|
console.error('❌ Erreur: Module EnglishExempleCommented non trouvé');
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('✅ Module JS chargé:');
|
|
console.log(` - ${Object.keys(englishModule.vocabulary).length} mots de vocabulaire`);
|
|
console.log(` - ${englishModule.sentences?.length || 0} phrases`);
|
|
console.log(` - ${englishModule.texts?.length || 0} textes`);
|
|
console.log(` - ${englishModule.dialogues?.length || 0} dialogues`);
|
|
console.log('');
|
|
|
|
// Fonction de conversion COMPLÈTE (toutes les données JS)
|
|
function convertToUltraModular(jsModule) {
|
|
const ultraModular = {
|
|
// ========================================
|
|
// CORE METADATA - Conversion honnête
|
|
// ========================================
|
|
id: "english_exemple_commented_from_js",
|
|
name: jsModule.name || "English Example Commented",
|
|
description: jsModule.description || "Converted from JavaScript module",
|
|
|
|
// Difficulté: on peut l'inférer du champ difficulty s'il existe
|
|
difficulty_level: jsModule.difficulty === 'intermediate' ? 5 :
|
|
jsModule.difficulty === 'easy' ? 3 :
|
|
jsModule.difficulty === 'hard' ? 7 : 4,
|
|
|
|
// Langues détectées
|
|
original_lang: jsModule.language || "english",
|
|
user_lang: "french", // Détecté depuis les traductions
|
|
|
|
// Icon simple
|
|
icon: "📚",
|
|
|
|
// Tags basés sur le contenu réel
|
|
tags: [],
|
|
|
|
// Skills covered si disponible
|
|
skills_covered: jsModule.skills_covered || [],
|
|
|
|
// ========================================
|
|
// VOCABULARY - Conversion fidèle avec tous les niveaux
|
|
// ========================================
|
|
vocabulary: {},
|
|
|
|
// ========================================
|
|
// GRAMMAR - Système de grammaire complet
|
|
// ========================================
|
|
grammar: {},
|
|
|
|
// ========================================
|
|
// SENTENCES - Conversion fidèle
|
|
// ========================================
|
|
sentences: [],
|
|
|
|
// ========================================
|
|
// TEXTS - Conversion fidèle
|
|
// ========================================
|
|
texts: [],
|
|
|
|
// ========================================
|
|
// DIALOGUES - Conversion fidèle
|
|
// ========================================
|
|
dialogues: [],
|
|
|
|
// ========================================
|
|
// AUDIO - Contenu audio
|
|
// ========================================
|
|
audio: [],
|
|
|
|
// ========================================
|
|
// CORRECTIONS - Exercices de correction
|
|
// ========================================
|
|
corrections: [],
|
|
|
|
// ========================================
|
|
// FILL-IN-BLANKS - Exercices fill-in-blanks
|
|
// ========================================
|
|
fillInBlanks: [],
|
|
|
|
// ========================================
|
|
// CULTURAL - Contenu culturel
|
|
// ========================================
|
|
cultural: {},
|
|
|
|
// ========================================
|
|
// MATCHING - Exercices de matching
|
|
// ========================================
|
|
matching: [],
|
|
|
|
// ========================================
|
|
// METADATA - Pour tracer la conversion
|
|
// ========================================
|
|
conversion_metadata: {
|
|
converted_from: "javascript_module",
|
|
conversion_timestamp: new Date().toISOString(),
|
|
source_file: "english-exemple-commented.js",
|
|
conversion_system: "honest_converter_v3.0_complete",
|
|
conversion_notes: "Conversion complète de toutes les données JS"
|
|
}
|
|
};
|
|
|
|
// ========================================
|
|
// VOCABULARY - Conversion complète avec tous les niveaux
|
|
// ========================================
|
|
if (jsModule.vocabulary) {
|
|
for (const [word, translation] of Object.entries(jsModule.vocabulary)) {
|
|
if (typeof translation === 'string') {
|
|
// Format simple: garder tel quel
|
|
ultraModular.vocabulary[word] = {
|
|
user_language: translation,
|
|
original_language: word
|
|
};
|
|
} else if (typeof translation === 'object') {
|
|
// Objet complet: préserver toutes les propriétés
|
|
ultraModular.vocabulary[word] = {
|
|
user_language: translation.translation || translation.french || translation,
|
|
original_language: word
|
|
};
|
|
|
|
// Ajouter toutes les propriétés qui existent
|
|
if (translation.type) ultraModular.vocabulary[word].type = translation.type;
|
|
if (translation.pronunciation) ultraModular.vocabulary[word].pronunciation = translation.pronunciation;
|
|
if (translation.audio) ultraModular.vocabulary[word].audio = translation.audio;
|
|
if (translation.image) ultraModular.vocabulary[word].image = translation.image;
|
|
if (translation.examples) ultraModular.vocabulary[word].examples = translation.examples;
|
|
if (translation.grammarNotes) ultraModular.vocabulary[word].grammarNotes = translation.grammarNotes;
|
|
if (translation.conjugation) ultraModular.vocabulary[word].conjugation = translation.conjugation;
|
|
if (translation.difficulty_context) ultraModular.vocabulary[word].difficulty_context = translation.difficulty_context;
|
|
if (translation.cultural_note) ultraModular.vocabulary[word].cultural_note = translation.cultural_note;
|
|
}
|
|
}
|
|
}
|
|
|
|
// ========================================
|
|
// GRAMMAR - Conversion complète
|
|
// ========================================
|
|
if (jsModule.grammar) {
|
|
ultraModular.grammar = jsModule.grammar;
|
|
}
|
|
|
|
// ========================================
|
|
// SENTENCES - Conversion fidèle
|
|
// ========================================
|
|
if (jsModule.sentences && Array.isArray(jsModule.sentences)) {
|
|
ultraModular.sentences = jsModule.sentences.map((sentence, idx) => ({
|
|
id: `sentence_${idx + 1}`,
|
|
original_language: sentence.english || sentence.original,
|
|
user_language: sentence.french || sentence.translation
|
|
}));
|
|
}
|
|
|
|
// ========================================
|
|
// TEXTS - Conversion complète avec exercices
|
|
// ========================================
|
|
if (jsModule.texts && Array.isArray(jsModule.texts)) {
|
|
ultraModular.texts = jsModule.texts.map((text, idx) => {
|
|
const convertedText = {
|
|
id: `text_${idx + 1}`,
|
|
title: text.title,
|
|
original_language: text.content || text.english,
|
|
user_language: text.translation || text.french
|
|
};
|
|
|
|
// Ajouter les exercices s'ils existent
|
|
if (text.questions) convertedText.questions = text.questions;
|
|
if (text.fillInBlanks) convertedText.fillInBlanks = text.fillInBlanks;
|
|
|
|
return convertedText;
|
|
});
|
|
}
|
|
|
|
// ========================================
|
|
// DIALOGUES - Conversion fidèle
|
|
// ========================================
|
|
if (jsModule.dialogues && Array.isArray(jsModule.dialogues)) {
|
|
ultraModular.dialogues = jsModule.dialogues.map((dialogue, idx) => ({
|
|
id: `dialogue_${idx + 1}`,
|
|
title: dialogue.title,
|
|
conversation: dialogue.conversation.map((line, lineIdx) => ({
|
|
id: `line_${lineIdx + 1}`,
|
|
speaker: line.speaker,
|
|
original_language: line.english,
|
|
user_language: line.french
|
|
}))
|
|
}));
|
|
}
|
|
|
|
// ========================================
|
|
// AUDIO - Conversion complète
|
|
// ========================================
|
|
if (jsModule.audio && Array.isArray(jsModule.audio)) {
|
|
ultraModular.audio = jsModule.audio;
|
|
}
|
|
|
|
// ========================================
|
|
// CORRECTIONS - Exercices de correction
|
|
// ========================================
|
|
if (jsModule.corrections && Array.isArray(jsModule.corrections)) {
|
|
ultraModular.corrections = jsModule.corrections;
|
|
}
|
|
|
|
// ========================================
|
|
// FILL-IN-BLANKS - Exercices fill-in-blanks
|
|
// ========================================
|
|
if (jsModule.fillInBlanks && Array.isArray(jsModule.fillInBlanks)) {
|
|
ultraModular.fillInBlanks = jsModule.fillInBlanks;
|
|
}
|
|
|
|
// ========================================
|
|
// CULTURAL - Contenu culturel complet
|
|
// ========================================
|
|
if (jsModule.cultural) {
|
|
ultraModular.cultural = jsModule.cultural;
|
|
}
|
|
|
|
// ========================================
|
|
// MATCHING - Exercices de matching
|
|
// ========================================
|
|
if (jsModule.matching && Array.isArray(jsModule.matching)) {
|
|
ultraModular.matching = jsModule.matching;
|
|
}
|
|
|
|
// ========================================
|
|
// TAGS basés sur le contenu RÉEL
|
|
// ========================================
|
|
if (Object.keys(ultraModular.vocabulary).length > 0) ultraModular.tags.push("vocabulary");
|
|
if (ultraModular.sentences.length > 0) ultraModular.tags.push("sentences");
|
|
if (ultraModular.texts.length > 0) ultraModular.tags.push("texts");
|
|
if (ultraModular.dialogues.length > 0) ultraModular.tags.push("dialogues");
|
|
if (ultraModular.grammar && Object.keys(ultraModular.grammar).length > 0) ultraModular.tags.push("grammar");
|
|
if (ultraModular.audio && ultraModular.audio.length > 0) ultraModular.tags.push("audio");
|
|
if (ultraModular.corrections && ultraModular.corrections.length > 0) ultraModular.tags.push("corrections");
|
|
if (ultraModular.fillInBlanks && ultraModular.fillInBlanks.length > 0) ultraModular.tags.push("fillInBlanks");
|
|
if (ultraModular.cultural && Object.keys(ultraModular.cultural).length > 0) ultraModular.tags.push("cultural");
|
|
if (ultraModular.matching && ultraModular.matching.length > 0) ultraModular.tags.push("matching");
|
|
ultraModular.tags.push("converted_from_js");
|
|
|
|
// ========================================
|
|
// STATS COMPLÈTES de conversion
|
|
// ========================================
|
|
ultraModular.conversion_metadata.stats = {
|
|
vocabulary_count: Object.keys(ultraModular.vocabulary).length,
|
|
sentence_count: ultraModular.sentences.length,
|
|
text_count: ultraModular.texts.length,
|
|
dialogue_count: ultraModular.dialogues.length,
|
|
grammar_count: ultraModular.grammar ? Object.keys(ultraModular.grammar).length : 0,
|
|
audio_count: ultraModular.audio ? ultraModular.audio.length : 0,
|
|
corrections_count: ultraModular.corrections ? ultraModular.corrections.length : 0,
|
|
fillInBlanks_count: ultraModular.fillInBlanks ? ultraModular.fillInBlanks.length : 0,
|
|
cultural_sections_count: ultraModular.cultural ? Object.keys(ultraModular.cultural).length : 0,
|
|
matching_count: ultraModular.matching ? ultraModular.matching.length : 0,
|
|
skills_covered_count: ultraModular.skills_covered ? ultraModular.skills_covered.length : 0
|
|
};
|
|
|
|
return ultraModular;
|
|
}
|
|
|
|
// Effectuer la conversion
|
|
console.log('🔄 Conversion en cours...');
|
|
const ultraModularJSON = convertToUltraModular(englishModule);
|
|
|
|
console.log('✅ Conversion COMPLÈTE terminée!');
|
|
console.log(` - ${Object.keys(ultraModularJSON.vocabulary).length} mots convertis`);
|
|
console.log(` - ${ultraModularJSON.sentences.length} phrases converties`);
|
|
console.log(` - ${ultraModularJSON.texts.length} textes convertis`);
|
|
console.log(` - ${ultraModularJSON.dialogues.length} dialogues convertis`);
|
|
console.log(` - ${ultraModularJSON.conversion_metadata.stats.grammar_count} leçons de grammaire`);
|
|
console.log(` - ${ultraModularJSON.conversion_metadata.stats.audio_count} contenus audio`);
|
|
console.log(` - ${ultraModularJSON.conversion_metadata.stats.corrections_count} exercices de correction`);
|
|
console.log(` - ${ultraModularJSON.conversion_metadata.stats.fillInBlanks_count} exercices fill-in-blanks`);
|
|
console.log(` - ${ultraModularJSON.conversion_metadata.stats.cultural_sections_count} sections culturelles`);
|
|
console.log(` - ${ultraModularJSON.conversion_metadata.stats.matching_count} exercices de matching`);
|
|
console.log(` - ${ultraModularJSON.conversion_metadata.stats.skills_covered_count} compétences couvertes`);
|
|
console.log('');
|
|
|
|
// Sauvegarder le fichier JSON
|
|
const fs = require('fs');
|
|
const outputFile = 'english-exemple-commented-GENERATED.json';
|
|
const jsonContent = JSON.stringify(ultraModularJSON, null, 2);
|
|
|
|
try {
|
|
fs.writeFileSync(outputFile, jsonContent, 'utf8');
|
|
console.log(`📁 Fichier JSON généré: ${outputFile}`);
|
|
console.log(`📏 Taille: ${(jsonContent.length / 1024).toFixed(1)} KB`);
|
|
console.log(`📄 Lignes: ${jsonContent.split('\n').length}`);
|
|
console.log('');
|
|
|
|
// Validation finale
|
|
const reloaded = JSON.parse(jsonContent);
|
|
console.log('✅ VALIDATION:');
|
|
console.log(` - JSON valide: ✅`);
|
|
console.log(` - ID: ${reloaded.id}`);
|
|
console.log(` - Nom: ${reloaded.name}`);
|
|
console.log(` - Tags: ${reloaded.tags.join(', ')}`);
|
|
console.log(` - Conversion honnête: ✅ (pas de données inventées)`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ Erreur:', error.message);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('================================================================');
|
|
console.log('🎉 Conversion JS → JSON Ultra-Modulaire RÉUSSIE (honnête)!'); |