feat: atalhos de navegação Q/E e correções no i18n
This commit is contained in:
107
translate_app.cjs
Normal file
107
translate_app.cjs
Normal file
@@ -0,0 +1,107 @@
|
||||
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</g, to: '>{t(\'dob\')}<' },
|
||||
{ from: />Localidade</g, to: '>{t(\'location\')}<' },
|
||||
{ from: />Bio</g, to: '>{t(\'bio\')}<' },
|
||||
{ from: />Peças Registadas</g, to: '>{t(\'registeredPieces\')}<' },
|
||||
{ from: />Outfits Criados</g, to: '>{t(\'createdOutfits\')}<' },
|
||||
{ from: />Data de Registo da Conta</g, to: '>{t(\'accountRegistrationDate\')}<' },
|
||||
{ from: />Atalhos de Teclado</g, to: '>{t(\'keyboardShortcuts\')}<' },
|
||||
{ from: />Ativar navegação com Q e E</g, to: '>{t(\'enableNavigationQE\')}<' },
|
||||
{ from: />Notificação do Outfit Diário</g, to: '>{t(\'dailyOutfitNotification\')}<' },
|
||||
{ from: />Receber notificação com o outfit planeado à hora marcada</g, to: '>{t(\'receiveNotificationAtScheduledTime\')}<' },
|
||||
{ from: />Cima</g, to: '>{t(\'up\')}<' },
|
||||
{ from: />Baixo</g, to: '>{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.');
|
||||
Reference in New Issue
Block a user