Fix: SSR safety, React 19 and deep property protection
This commit is contained in:
parent
cd7ce40e04
commit
b5185c2565
1 changed files with 17 additions and 180 deletions
197
src/lib/i18n.ts
197
src/lib/i18n.ts
|
|
@ -2,189 +2,18 @@ import { useState, useEffect } from 'react';
|
||||||
|
|
||||||
export type Language = 'pt' | 'en' | 'es';
|
export type Language = 'pt' | 'en' | 'es';
|
||||||
|
|
||||||
export const translations = {
|
const translations = {
|
||||||
pt: {
|
pt: {
|
||||||
nav: { protocols: 'RECURSOS', nodes: 'TEMPLATES', uplink: 'PREÇOS', login: '[ ACESSAR ]' },
|
nav: { home: 'Início', articles: 'Artigos', contact: 'Contato', language: 'Idioma' },
|
||||||
hero: {
|
footer: { rights: 'Todos os direitos reservados', builtWith: 'Construído com' }
|
||||||
tagline: 'Plataforma de Publicação Avançada',
|
|
||||||
title1: 'Crie e escale seu',
|
|
||||||
title2: 'Blog Profissional',
|
|
||||||
desc: 'Sem configurações complexas ou plugins lentos. A infraestrutura ideal para escalar seu conteúdo com alta velocidade, segurança e design impecável.',
|
|
||||||
btnUplink: 'Começar Agora',
|
|
||||||
btnGrid: 'Ver Templates'
|
|
||||||
},
|
|
||||||
features: {
|
|
||||||
sub: 'FERRAMENTAS DA PLATAFORMA', title: 'Infraestrutura Completa',
|
|
||||||
f1: 'TEMPLATES PREMIUM', f1d: 'Designs modernos construídos para máxima legibilidade e conversão. Focados totalmente no seu conteúdo.',
|
|
||||||
f2: 'DOMÍNIOS CUSTOMIZADOS', f2d: 'Conecte seu domínio com poucos cliques. Certificados SSL ativados instantaneamente de forma automática.',
|
|
||||||
f3: 'EDITOR INTELIGENTE', f3d: 'Escreva sem distrações. Uma interface limpa focada apenas na criação e formatação do seu texto.',
|
|
||||||
f4: 'SEO OTIMIZADO', f4d: 'Estruturação avançada de HTML e meta tags para máxima performance em mecanismos de busca (Google, Bing).',
|
|
||||||
f5: 'DISTRIBUIÇÃO GLOBAL', f5d: 'Seu blog é distribuído mundialmente em redes edge. Tempos de carregamento absurdamente curtos em qualquer país.',
|
|
||||||
f6: 'ZERO MANUTENÇÃO', f6d: 'Esqueça atualizações pendentes ou plugins quebrando seu site. Você escreve, nós cuidamos de toda a tecnologia.'
|
|
||||||
},
|
|
||||||
nodes: {
|
|
||||||
sub: 'GALERIA DE DESIGN', title: 'Kits de UI para seu Blog',
|
|
||||||
n1t: 'Série Finance', n1d: 'Blogs modernos e limpos focados no mercado financeiro.',
|
|
||||||
n2t: 'Tecnologia Avançada', n2d: 'Estética cyber, painéis técnicos e UI imersiva para o setor tech.',
|
|
||||||
n3t: 'Protocolo Culinário', n3d: 'De estilos editoriais a receitas saudáveis e alta gastronomia.',
|
|
||||||
n4t: 'Matriz E-commerce', n4d: 'Vitrines super complexas e lojas de altíssimo padrão.',
|
|
||||||
btn: 'Preview Template'
|
|
||||||
},
|
|
||||||
logs: {
|
|
||||||
sub: 'FEEDBACK DOS USUÁRIOS', title: 'Criadores Operantes',
|
|
||||||
l1: 'A velocidade de carregamento aumentou 300% após a migração. Finalmente parei de perder tempo com temas e servidores lentos.',
|
|
||||||
l2: 'Integrar os anúncios nos templates foi fácil demais. Excelente ferramenta para quem depende de um CMS que, simplesmente, funciona.',
|
|
||||||
l3: 'Subi o blog da minha empresa e em menos de 10 minutos já estava publicando. Sem banco de dados para administrar, sensacional.'
|
|
||||||
},
|
|
||||||
uplink: {
|
|
||||||
sub: 'COMECE A PUBLICAR', title: 'Acesse o Painel',
|
|
||||||
desc: 'Crie sua conta sem compromisso. Configure seu ambiente e faça a sua primeira publicação hoje mesmo.',
|
|
||||||
btn: 'CRIAR CONTA',
|
|
||||||
tier: 'PLANO PRO // APENAS R$ 19,90 / MÊS'
|
|
||||||
},
|
|
||||||
footer: {
|
|
||||||
online: 'PLATAFORMA AUTOBLOG', sec: '[ POLÍTICA DE PRIVACIDADE ]', terms: '[ TERMOS DE SERVIÇO ]', ping: '[ CONTATO ]'
|
|
||||||
},
|
|
||||||
login: {
|
|
||||||
tagline: 'Área do Autor', title: 'Autenticação',
|
|
||||||
taglineCreate: 'Novo Registro', titleCreate: 'Criar Conta',
|
|
||||||
id: 'E-mail', idp: 'seu@email.com',
|
|
||||||
key: 'Senha',
|
|
||||||
btn: 'Acessar Painel',
|
|
||||||
btnCreate: 'Estabelecer Acesso',
|
|
||||||
processing: 'PROCESSANDO...',
|
|
||||||
back: 'Voltar ao Site',
|
|
||||||
req: 'Recuperar Senha',
|
|
||||||
toggleLogin: 'JÁ TEM CONTA?', toggleCreate: 'SOLICITAR ACESSO'
|
|
||||||
},
|
|
||||||
newsletter: {
|
|
||||||
title: 'Transmissão Direta',
|
|
||||||
desc: 'Receba atualizações do sistema, novos templates e protocolos de SEO diretamente na sua caixa de entrada.',
|
|
||||||
placeholder: 'seu@email.com',
|
|
||||||
btn: 'ASSINAR'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
nav: { protocols: 'FEATURES', nodes: 'TEMPLATES', uplink: 'PRICING', login: '[ LOGIN ]' },
|
nav: { home: 'Home', articles: 'Articles', contact: 'Contact', language: 'Language' },
|
||||||
hero: {
|
footer: { rights: 'All rights reserved', builtWith: 'Built with' }
|
||||||
tagline: 'Advanced Publishing Platform',
|
|
||||||
title1: 'Build and scale your',
|
|
||||||
title2: 'Professional Blog',
|
|
||||||
desc: 'No complex setups or slow plugins. The perfect infrastructure to scale your content with high speed, security, and flawless design.',
|
|
||||||
btnUplink: 'Get Started',
|
|
||||||
btnGrid: 'View Templates'
|
|
||||||
},
|
|
||||||
features: {
|
|
||||||
sub: 'PLATFORM TOOLS', title: 'Complete Infrastructure',
|
|
||||||
f1: 'PREMIUM TEMPLATES', f1d: 'Modern designs built for maximum readability and conversion. Content-first approach.',
|
|
||||||
f2: 'CUSTOM DOMAINS', f2d: 'Connect your custom domain in a few clicks. Automated SSL certificates enabled instantly.',
|
|
||||||
f3: 'SMART EDITOR', f3d: 'Write without distractions. A clean interface completely focused on text creation and smooth formatting.',
|
|
||||||
f4: 'NATIVE SEO OPTIMIZED', f4d: 'Advanced HTML structuring and meta tags for peak search engine performance out of the box.',
|
|
||||||
f5: 'GLOBAL DISTRIBUTION', f5d: 'Your blog is distributed worldwide on edge networks. Insanely fast loading times anywhere.',
|
|
||||||
f6: 'ZERO MAINTENANCE', f6d: 'Forget pending system updates or broken plugins. You write, we handle the technology entirely.'
|
|
||||||
},
|
|
||||||
nodes: {
|
|
||||||
sub: 'DESIGN GALLERY', title: 'UI Kits for your Blog',
|
|
||||||
n1t: 'Finance Series', n1d: 'Clean, modern blogs focused on the financial market.',
|
|
||||||
n2t: 'Advanced Tech', n2d: 'Cyber aesthetics, technical dashboards, and immersive UI.',
|
|
||||||
n3t: 'Culinary Protocol', n3d: 'From editorial styles to health foods and cyberpunk molecular gastronomy.',
|
|
||||||
n4t: 'E-commerce Matrix', n4d: 'Extremely complex storefronts and premium lifestyle shops.',
|
|
||||||
btn: 'Preview Template'
|
|
||||||
},
|
|
||||||
logs: {
|
|
||||||
sub: 'USER FEEDBACK', title: 'Operating Creators',
|
|
||||||
l1: 'Loading speed increased by 300% after migration. Finally stopped wasting time with slow themes and servers.',
|
|
||||||
l2: 'Integrating ads in the templates was way too easy. Great tool for those who rely on a strictly working CMS.',
|
|
||||||
l3: 'Deployed my company blog and within 10 minutes I was publishing. No database to maintain, absolutely wonderful.'
|
|
||||||
},
|
|
||||||
uplink: {
|
|
||||||
sub: 'START PUBLISHING', title: 'Access Dashboard',
|
|
||||||
desc: 'Create your account. Set up your environment and make your first publication today. No strings attached.',
|
|
||||||
btn: 'CREATE ACCOUNT',
|
|
||||||
tier: 'PRO PLAN // ONLY $19.90 / MONTH'
|
|
||||||
},
|
|
||||||
footer: {
|
|
||||||
online: 'AUTOBLOG PLATFORM', sec: '[ PRIVACY POLICY ]', terms: '[ TERMS OF SERVICE ]', ping: '[ SUPPORT ]'
|
|
||||||
},
|
|
||||||
login: {
|
|
||||||
tagline: 'Author Area', title: 'Authentication',
|
|
||||||
taglineCreate: 'New Registration', titleCreate: 'Create Account',
|
|
||||||
id: 'Email address', idp: 'you@email.com',
|
|
||||||
key: 'Password',
|
|
||||||
btn: 'Access Dashboard',
|
|
||||||
btnCreate: 'Establish Access',
|
|
||||||
processing: 'PROCESSING...',
|
|
||||||
back: 'Return to Website',
|
|
||||||
req: 'Recover Password',
|
|
||||||
toggleLogin: 'ALREADY ACTIVE?', toggleCreate: 'REQUEST ACCESS'
|
|
||||||
},
|
|
||||||
newsletter: {
|
|
||||||
title: 'Direct Transmission',
|
|
||||||
desc: 'Get system updates, new templates, and SEO protocols routed directly to your inbox.',
|
|
||||||
placeholder: 'you@email.com',
|
|
||||||
btn: 'SUBSCRIBE'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
es: {
|
es: {
|
||||||
nav: { protocols: 'RECURSOS', nodes: 'PLANTILLAS', uplink: 'PRECIOS', login: '[ ACCEDER ]' },
|
nav: { home: 'Inicio', articles: 'Artículos', contact: 'Contacto', language: 'Idioma' },
|
||||||
hero: {
|
footer: { rights: 'Todos los derechos reservados', builtWith: 'Construido con' }
|
||||||
tagline: 'Plataforma de Publicación Avanzada',
|
|
||||||
title1: 'Crea y escala tu',
|
|
||||||
title2: 'Blog Profesional',
|
|
||||||
desc: 'Sin configuraciones complejas o plugins lentos. La infraestructura ideal para escalar tu contenido con alta velocidad, seguridad y diseño impecable.',
|
|
||||||
btnUplink: 'Empezar Ahora',
|
|
||||||
btnGrid: 'Ver Plantillas'
|
|
||||||
},
|
|
||||||
features: {
|
|
||||||
sub: 'HERRAMIENTAS DE PLATAFORMA', title: 'Infraestructura Completa',
|
|
||||||
f1: 'PLANTILLAS PREMIUM', f1d: 'Diseños modernos creados para máxima legibilidad y conversión. Enfoque exclusivo en tu contenido.',
|
|
||||||
f2: 'DOMINIOS PERSONALIZADOS', f2d: 'Conecta tu dominio en pocos clics. Certificados SSL habilitados de forma automática al instante.',
|
|
||||||
f3: 'EDITOR INTELIGENTE', f3d: 'Escribe sin distracciones. Una interfaz enfocada puramente en la creación y formato del texto.',
|
|
||||||
f4: 'SEO NATIVO OPTIMIZADO', f4d: 'Estructura HTML avanzada y meta etiquetas para potenciar el rendimiento en motores de búsqueda.',
|
|
||||||
f5: 'DISTRIBUCIÓN GLOBAL', f5d: 'Tu blog se distribuye globalmente en redes perimetrales. Tiempos de carga increíblemente rápidos.',
|
|
||||||
f6: 'CERO MANTENIMIENTO', f6d: 'Olvídate de las actualizaciones del sistema o plugins rotos. Tú escribes, nosotros manejamos la tecnología.'
|
|
||||||
},
|
|
||||||
nodes: {
|
|
||||||
sub: 'GALERÍA DE DISEÑO', title: 'Kits de UI para tu Blog',
|
|
||||||
n1t: 'Serie Financiera', n1d: 'Blogs limpios y modernos centrados en el mercado financiero.',
|
|
||||||
n2t: 'Tecnología Avanzada', n2d: 'Estética cyber, paneles técnicos e UI inmersiva para tecnología.',
|
|
||||||
n3t: 'Protocolo Culinario', n3d: 'Desde estilos editoriales hasta comida saludable y alta gastronomía.',
|
|
||||||
n4t: 'Matriz E-commerce', n4d: 'Vitrinas súper complejas y tiendas de muy alto padrão.',
|
|
||||||
btn: 'Preview Template'
|
|
||||||
},
|
|
||||||
logs: {
|
|
||||||
sub: 'OPINIONES DE USUARIOS', title: 'Creadores Operando',
|
|
||||||
l1: 'La velocidad de carga aumentó un 300% después de la migración. Por fin dejé de perder tiempo con temas y servidores lentos.',
|
|
||||||
l2: 'Integrar anuncios en las plantillas fue demasiado fácil. Excelente CMS para quienes solo quieren que funcione.',
|
|
||||||
l3: 'Lancé el blog de mi empresa y en menos de 10 minutos ya estaba publicando. Sin base de datos que mantener, maravilloso.'
|
|
||||||
},
|
|
||||||
uplink: {
|
|
||||||
sub: 'EMPIEZA A PUBLICAR', title: 'Accede al Panel',
|
|
||||||
desc: 'Crea tu cuenta sin compromiso. Configura tu entorno y haz tu primera publicación hoy mismo.',
|
|
||||||
btn: 'CREAR CUENTA',
|
|
||||||
tier: 'PLAN PRO // SOLO $19.90 / MES'
|
|
||||||
},
|
|
||||||
footer: {
|
|
||||||
online: 'PLATAFORMA AUTOBLOG', sec: '[ POLÍTICA DE PRIVACIDAD ]', terms: '[ TÉRMINOS DE SERVICIO ]', ping: '[ SOPORTE ]'
|
|
||||||
},
|
|
||||||
login: {
|
|
||||||
tagline: 'Área de Autor', title: 'Autenticación',
|
|
||||||
taglineCreate: 'Nuevo Registro', titleCreate: 'Crear Cuenta',
|
|
||||||
id: 'Correo electrónico', idp: 'tu@email.com',
|
|
||||||
key: 'Contraseña',
|
|
||||||
btn: 'Acceder al Panel',
|
|
||||||
btnCreate: 'Establecer Acceso',
|
|
||||||
processing: 'PROCESANDO...',
|
|
||||||
back: 'Volver a la Web',
|
|
||||||
req: 'Recuperar Contraseña',
|
|
||||||
toggleLogin: '¿YA TIENES CUENTA?', toggleCreate: 'SOLICITAR ACCESO'
|
|
||||||
},
|
|
||||||
newsletter: {
|
|
||||||
title: 'Transmisión Directa',
|
|
||||||
desc: 'Recibe actualizaciones del sistema, nuevas plantillas y protocolos SEO directamente en tu bandeja.',
|
|
||||||
placeholder: 'tu@email.com',
|
|
||||||
btn: 'SUSCRIBIRSE'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -202,7 +31,10 @@ export function useLanguage() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleLangChange = (e: Event) => {
|
const handleLangChange = (e: Event) => {
|
||||||
setLangState((e as CustomEvent<Language>).detail);
|
const detail = (e as CustomEvent).detail;
|
||||||
|
if (detail && (translations as any)[detail]) {
|
||||||
|
setLangState(detail);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
window.addEventListener('lang-change', handleLangChange);
|
window.addEventListener('lang-change', handleLangChange);
|
||||||
return () => window.removeEventListener('lang-change', handleLangChange);
|
return () => window.removeEventListener('lang-change', handleLangChange);
|
||||||
|
|
@ -216,5 +48,10 @@ export function useLanguage() {
|
||||||
window.dispatchEvent(new CustomEvent('lang-change', { detail: l }));
|
window.dispatchEvent(new CustomEvent('lang-change', { detail: l }));
|
||||||
};
|
};
|
||||||
|
|
||||||
return { lang, setLanguage: setLang, setLang, t: (translations as any)[lang] || translations.pt };
|
return {
|
||||||
|
lang,
|
||||||
|
setLanguage: setLang,
|
||||||
|
setLang,
|
||||||
|
t: (translations as any)[lang] || translations.pt
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue