const fs = require('fs'); // 1. Update i18n.js let i18nCode = fs.readFileSync('src/lib/i18n.js', 'utf8'); const newTranslations = { PT: { registeredPieces: "Peças Registadas", createdOutfits: "Outfits Criados", accountRegistrationDate: "Data de Registo da Conta", keyboardShortcuts: "Atalhos de Teclado", enableNavigationQE: "Ativar navegação com Q e E", dailyOutfitNotification: "Notificação do Outfit Diário", receiveNotificationAtScheduledTime: "Receber notificação com o outfit planeado à hora marcada", up: "Cima", down: "Baixo" }, EN: { registeredPieces: "Registered Pieces", createdOutfits: "Created Outfits", accountRegistrationDate: "Account Registration Date", keyboardShortcuts: "Keyboard Shortcuts", enableNavigationQE: "Enable navigation with Q and E", dailyOutfitNotification: "Daily Outfit Notification", receiveNotificationAtScheduledTime: "Receive notification with the planned outfit at the scheduled time", up: "Up", down: "Down" }, ES: { registeredPieces: "Piezas Registradas", createdOutfits: "Outfits Creados", accountRegistrationDate: "Fecha de Registro de la Cuenta", keyboardShortcuts: "Atajos de Teclado", enableNavigationQE: "Habilitar navegación con Q y E", dailyOutfitNotification: "Notificación del Outfit Diario", receiveNotificationAtScheduledTime: "Recibir notificación con el outfit planeado a la hora programada", up: "Arriba", down: "Abajo" }, FR: { registeredPieces: "Pièces Enregistrées", createdOutfits: "Outfits Créés", accountRegistrationDate: "Date d'Inscription du Compte", keyboardShortcuts: "Raccourcis Clavier", enableNavigationQE: "Activer la navigation avec Q et E", dailyOutfitNotification: "Notification de Tenue Quotidienne", receiveNotificationAtScheduledTime: "Recevoir une notification avec la tenue prévue à l'heure programmée", up: "Haut", down: "Bas" }, DE: { registeredPieces: "Registrierte Stücke", createdOutfits: "Erstellte Outfits", accountRegistrationDate: "Konto-Registrierungsdatum", keyboardShortcuts: "Tastenkombinationen", enableNavigationQE: "Navigation mit Q und E aktivieren", dailyOutfitNotification: "Tägliche Outfit-Benachrichtigung", receiveNotificationAtScheduledTime: "Benachrichtigung mit dem geplanten Outfit zur geplanten Zeit erhalten", up: "Oben", down: "Unten" } }; for (const lang in newTranslations) { const keys = newTranslations[lang]; const langRegex = new RegExp(`${lang}: \\{([\\s\\S]*?)\\}`, 'g'); let match = langRegex.exec(i18nCode); if (match) { let currentKeys = match[1]; let newKeysString = ""; for (const [k, v] of Object.entries(keys)) { if (!currentKeys.includes(`${k}:`)) { newKeysString += ` ${k}: "${v}",\n`; } } if (newKeysString.length > 0) { i18nCode = i18nCode.replace(currentKeys, currentKeys.trimEnd() + ",\n" + newKeysString); } } } fs.writeFileSync('src/lib/i18n.js', i18nCode); // 2. Update App.jsx let appCode = fs.readFileSync('src/App.jsx', 'utf8'); const replacements = [ { from: />Data de Nascimento{t(\'dob\')}<' }, { from: />Localidade{t(\'location\')}<' }, { from: />Bio{t(\'bio\')}<' }, { from: />Peças Registadas{t(\'registeredPieces\')}<' }, { from: />Outfits Criados{t(\'createdOutfits\')}<' }, { from: />Data de Registo da Conta{t(\'accountRegistrationDate\')}<' }, { from: />Atalhos de Teclado{t(\'keyboardShortcuts\')}<' }, { from: />Ativar navegação com Q e E{t(\'enableNavigationQE\')}<' }, { from: />Notificação do Outfit Diário{t(\'dailyOutfitNotification\')}<' }, { from: />Receber notificação com o outfit planeado à hora marcada{t(\'receiveNotificationAtScheduledTime\')}<' }, { from: />Cima{t(\'up\')}<' }, { from: />Baixo{t(\'down\')}<' } ]; replacements.forEach(r => { appCode = appCode.replace(r.from, r.to); }); fs.writeFileSync('src/App.jsx', appCode); console.log('App successfully translated and i18n updated.');