Class_generator/convert-vocabulary.js
StillHammer fe7153d28b Fix compatibility system and improve UX
- 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>
2025-09-18 19:29:21 +08:00

27 lines
987 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Quick script to convert old vocabulary format to new language-agnostic format
const fs = require('fs');
function convertVocabularyFormat(inputFile, outputFile) {
let content = fs.readFileSync(inputFile, 'utf8');
// Pattern to match: word: "translation",
const pattern = /(\s+)(\w+|"[^"]*"): "([^"]*)",?/g;
content = content.replace(pattern, (match, indent, word, translation) => {
// Determine word type based on translation or word
let type = "noun"; // Default
if (translation.includes("的") && !translation.includes("")) type = "adjective";
if (word.includes(" ")) type = "phrase";
return `${indent}${word}: { user_language: "${translation}", type: "${type}" },`;
});
fs.writeFileSync(outputFile, content);
console.log(`Converted ${inputFile} to ${outputFile}`);
}
// Convert the sbs file
convertVocabularyFormat(
'js/content/sbs-level-7-8-new.js',
'js/content/sbs-level-7-8-new-converted.js'
);