const express = require('express'); const router = express.Router(); const path = require('path'); const fs = require('fs'); // Function to load the appropriate language file function getLanguageFile(language) { const filePath = path.join(__dirname, `../locales/countdown/${language}.json`); return JSON.parse(fs.readFileSync(filePath, 'utf8')); } // Route for the card, with language support router.get('/:lang', (req, res) => { const lang = req.params.lang || 'en'; // Default to English let languageData; // Try to load the correct language file, fall back to English try { languageData = getLanguageFile(lang); } catch (err) { languageData = getLanguageFile('en'); } res.render('countdown', { langData: languageData}); }); module.exports = router;