Files
my_closet/patch_app.cjs

87 lines
4.8 KiB
JavaScript

const fs = require('fs');
let code = fs.readFileSync('src/App.jsx', 'utf8');
const replacements = [
// Laundry message remove
[`<p className="opacity-60 font-medium">{t('laundryMsg')}</p>`, ``],
// Create Section
[`<Plus size={10} /> Criar Secção`, `<Plus size={10} /> {t('createSection')}`],
[`Ainda não tem secções criadas`, `{t('noSectionsCreated')}`],
// Look card share tooltip
[`{copiedLookId === look.id ? 'Link copiado!' : 'Partilhar'}`, `{copiedLookId === look.id ? t('linkCopied') : t('share')}`],
// Laundry looks
[`peça(s) na lavandaria`, `{t('piecesInLaundry')}`],
[`A ser lavados`, `{t('toBeWashed')}`],
[`Indisponíveis`, `{t('unavailable')}`],
[`Disponíveis (`, `{t('availableLooks')} (`],
[`Nenhum look disponível`, `{t('noLooksAvailable')}`],
// Profile
[`<Input label="Localidade"`, `<Input label={t('location')}`],
[`placeholder="Ex: Lisboa, Portugal"`, `placeholder={t('locationEx')}`],
// Feedback
[`<Input label="Ideia / Sugestão"`, `<Input label={t('ideaSuggestion')}`],
[`<Input label="Bug / Erro"`, `<Input label={t('bugError')}`],
[`placeholder="Escreva aqui a sua mensagem..."`, `placeholder={t('writeMessage')}`],
[`Enviar Mensagem</button>`, `{t('sendMessage')}</button>`],
[`'Mensagem enviada com sucesso!'`, `t('msgSentSuccess')`],
[`'Erro ao enviar mensagem. Verifica a tua ligação.'`, `t('msgSendError')`],
// Notifications
[`Notificações</h3>`, `{t('notificationsModal')}</h3>`],
[`Sem Notificações`, `{t('noNotifications')}`],
[`O utilizador <span`, `{t('userTitle')} <span`],
[`guardou o seu look`, `{t('userSavedLook')}`],
[`no armário dele!`, `{t('inTheirCloset')}`],
// Shared Look Modal
[`Look Partilhado`, `{t('sharedLookTitle')}`],
[`Partilhado por`, `{t('sharedBy')}`],
[`'alguém'`, `t('someone')`],
[`Peças incluídas`, `{t('includedPieces')}`],
[`Ignorar`, `{t('ignore')}`],
[`A copiar...`, `{t('copying')}`],
[`Copiar para o meu armário`, `{t('copyToMyCloset')}`],
// Add Item wishlist
[`<p className="text-[10px] uppercase tracking-widest opacity-50">Adicionar peça como compra futura</p>`, `<p className="text-[10px] uppercase tracking-widest opacity-50">{t('addFuturePurchase')}</p>`],
[`<span className="font-bold text-sm text-inherit">Lista de Desejos</span>`, `<span className="font-bold text-sm text-inherit">{t('wishlistDesc')}</span>`],
// Settings
[`<h4 className="font-bold text-inherit">Suporte e Feedback</h4>`, `<h4 className="font-bold text-inherit">{t('feedbackTitle')}</h4>`],
[`<p className="text-xs text-inherit opacity-60">Tem alguma ideia, sugestão ou encontrou algum problema? Envie uma mensagem diretamente para nós!</p>`, `<p className="text-xs text-inherit opacity-60">{t('feedbackDesc')}</p>`],
[`<h4 className="font-bold text-inherit">Cor do Tema</h4>`, `<h4 className="font-bold text-inherit">{t('themeColorTitle')}</h4>`],
[`<p className="text-xs text-inherit opacity-60">Personalize a cor</p>`, `<p className="text-xs text-inherit opacity-60">{t('personalizeColorDesc')}</p>`],
[`Guardar Alterações`, `{t('saveChanges')}`]
];
for (const [oldText, newText] of replacements) {
code = code.split(oldText).join(newText);
}
// Color map replacement
const colorMapReplace = `['Vermelho', 'Azul', 'Amarelo', 'Verde', 'Laranja', 'Roxo', 'Branco', 'Preto', 'Cinzento', 'Bege'].map(c => (`;
if(code.includes(colorMapReplace)) {
code = code.replace(
colorMapReplace,
`['Vermelho', 'Azul', 'Amarelo', 'Verde', 'Laranja', 'Roxo', 'Branco', 'Preto', 'Cinzento', 'Bege'].map(c => {\n const translatedColor = c === 'Vermelho' ? t('colorRed') : c === 'Azul' ? t('colorBlue') : c === 'Amarelo' ? t('colorYellow') : c === 'Verde' ? t('colorGreen') : c === 'Laranja' ? t('colorOrange') : c === 'Roxo' ? t('colorPurple') : c === 'Branco' ? t('colorWhite') : c === 'Preto' ? t('colorBlack') : c === 'Cinzento' ? t('colorGray') : c === 'Bege' ? t('colorBeige') : c;\n return (`
);
// Be very precise replacing `{c}` to `{translatedColor}`
code = code.replace(
/className=\{\`px-4 py-2 rounded-xl text-xs font-bold transition-all border-2 \$\{itemColors\.includes\(c\) \? 'border-primary-600 bg-primary-600 text-white shadow-lg shadow-primary-600\/30' : 'border-transparent bg-gray-100 dark:bg-gray-800 text-gray-500 hover:bg-gray-200 dark:hover:bg-gray-700'\}\`\}\n\s*>\n\s*\{c\}\n\s*<\/button>/,
match => match.replace('{c}', '{translatedColor}')
);
// Replace the closing block
code = code.replace(
/<\/button>\n\s*\)\)/,
`</button>\n )})`
);
}
fs.writeFileSync('src/App.jsx', code);
console.log('App.jsx updated successfully');