From b7c59c63050b10ddafa460c45400809626c2f2fc Mon Sep 17 00:00:00 2001 From: Vitor Moreira <230419@epvc.pt> Date: Tue, 17 Mar 2026 10:34:47 +0000 Subject: [PATCH] config, language --- src/App.jsx | 208 +++++++++++++-------- src/lib/i18n.js | 468 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 606 insertions(+), 70 deletions(-) create mode 100644 src/lib/i18n.js diff --git a/src/App.jsx b/src/App.jsx index aa7ac5e..86a52bb 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -6,7 +6,7 @@ import { Edit2, Image as ImageIcon, Check, RotateCcw, Trash, PanelLeftClose, PanelLeftOpen, Sparkles, CloudSun, ArrowRight, Droplets, CheckCircle2, PieChart, History, - X + X, Download, Bell, Globe } from 'lucide-react'; import { @@ -22,6 +22,7 @@ import { auth, db, appId } from './lib/firebase'; import { Card } from './components/ui/Card'; import { Badge } from './components/ui/Badge'; import { Input } from './components/ui/Input'; +import { translations } from './lib/i18n'; export default function App() { const [view, setView] = useState('auth'); @@ -41,6 +42,13 @@ export default function App() { // Estado para criação de Looks const [selectedForLook, setSelectedForLook] = useState([]); + // Estado para Definições + const [notificationsEnabled, setNotificationsEnabled] = useState(true); + const [weatherAlerts, setWeatherAlerts] = useState(true); + const [language, setLanguage] = useState('PT'); + + const t = (key) => translations[language]?.[key] || translations['PT'][key] || key; + // 1. Inicializar Autenticação useEffect(() => { const initAuth = async () => { @@ -103,7 +111,7 @@ export default function App() { case 'restore': await updateDoc(docRef, { status: 'active', trashedAt: null }); break; case 'laundry': await updateDoc(docRef, { status: 'laundry' }); break; case 'clean': await updateDoc(docRef, { status: 'active' }); break; - case 'delete': if (window.confirm("Apagar permanentemente?")) await deleteDoc(docRef); break; + case 'delete': if (window.confirm(t('confirmDeletePerm'))) await deleteDoc(docRef); break; } }; @@ -160,7 +168,7 @@ export default function App() { }; const deleteLook = async (id) => { - if (!window.confirm("Apagar este Look?")) return; + if (!window.confirm(t('confirmDeleteLook'))) return; const docRef = doc(db, 'artifacts', appId, 'users', user.uid, 'looks', id); await deleteDoc(docRef); }; @@ -179,7 +187,7 @@ export default function App() { } catch (err) { console.error(err); if (err.code === 'auth/operation-not-allowed') { - setAuthError('O login por e-mail está desativado.'); + setAuthError(t('authErrorDisabled')); } else { setAuthError(err.message); } @@ -189,7 +197,7 @@ export default function App() { const emptyTrashPermanently = async () => { - if (!user || !window.confirm("Esvaziar o lixo permanentemente?")) return; + if (!user || !window.confirm(t('confirmEmptyTrash'))) return; setLoading(true); try { const batch = writeBatch(db); @@ -203,7 +211,7 @@ export default function App() { }; const clearAllToTrash = async () => { - if (!user || !window.confirm("Mover todas as peças ativas para o lixo?")) return; + if (!user || !window.confirm(t('confirmClearAll'))) return; setLoading(true); try { const batch = writeBatch(db); @@ -227,24 +235,22 @@ export default function App() {

MyCloset

-

O Futuro do Teu Estilo

+

{t('loginModeIntro')}

{authError &&
{authError}
}
- - + +
- -
@@ -271,11 +277,11 @@ export default function App() {