mirror of
https://github.com/phaleixo/after_install_debian_12.git
synced 2025-12-05 21:49:44 -03:00
modified: index.html
renamed: scripts/scripts.js -> scripts/index.js
This commit is contained in:
parent
ced6c8bcfb
commit
a9aead8740
295
index.html
295
index.html
@ -337,300 +337,7 @@ https://www.debian.org/download.pt.html</code></pre>
|
|||||||
transferência!</span>
|
transferência!</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script src="scripts/index.js"></script>
|
||||||
// Language translations
|
|
||||||
const translations = {
|
|
||||||
pt: {
|
|
||||||
"title": "Scripts de Pós-Instalação do Debian 12",
|
|
||||||
"hero.title": "Otimize Sua Experiência com o Debian 12 GNOME",
|
|
||||||
"hero.subtitle": "Uma coleção de scripts para personalizar e melhorar sua instalação do Debian 12 com aplicativos essenciais, codecs, ajustes e muito mais.",
|
|
||||||
"hero.download": "Baixar Debian 12",
|
|
||||||
"hero.viewScripts": "Ver Scripts",
|
|
||||||
"download.title": "Baixar Debian 12 GNOME",
|
|
||||||
"download.description": "Comece com a ISO live oficial do Debian 12 GNOME para usar esses scripts de pós-instalação.",
|
|
||||||
"download.button": "Baixar ISO",
|
|
||||||
"scripts.title": "Scripts de Pós-Instalação",
|
|
||||||
"scripts.complete.title": "Pós-Instalação Completa",
|
|
||||||
"scripts.complete.description": "Execute todas as alterações recomendadas incluindo ativação de repositórios, instalação de codecs, extensões GNOME e instalação de aplicativos.",
|
|
||||||
"scripts.repos.title": "Ativar Repositórios",
|
|
||||||
"scripts.repos.description": "Ative os repositórios contrib e non-free e instale suporte ao Flatpak com o repositório Flathub.",
|
|
||||||
"scripts.firefox.title": "Firefox Atual",
|
|
||||||
"scripts.firefox.description": "Mude do Firefox ESR para a versão de lançamento atual.",
|
|
||||||
"scripts.codecs.title": "Codecs & Ajustes",
|
|
||||||
"scripts.codecs.description": "Instale codecs multimídia, firmware, fontes e utilitários úteis.",
|
|
||||||
"scripts.extensions.title": "Extensões GNOME",
|
|
||||||
"scripts.extensions.description": "Instale extensões úteis do GNOME como Dash-to-Dock, Tiling Assistant e mais.",
|
|
||||||
"scripts.remove.title": "Remover Apps Desnecessários",
|
|
||||||
"scripts.remove.description": "Remova aplicativos pré-instalados desnecessários para limpar seu sistema.",
|
|
||||||
"scripts.apps.title": "Instalar Aplicativos",
|
|
||||||
"scripts.apps.description": "Instale aplicativos úteis via Flatpak incluindo GIMP, Inkscape e mais.",
|
|
||||||
"scripts.radeon.title": "Radeon para AMDGPU",
|
|
||||||
"scripts.radeon.description": "Mude do driver Radeon para AMDGPU para melhor desempenho com certas GPUs AMD.",
|
|
||||||
"scripts.fonts.title": "Instalar Fontes",
|
|
||||||
"scripts.fonts.description": "Instale e configure fontes adicionais para melhor tipografia.",
|
|
||||||
"scripts.wallpapers.title": "Instalar Papéis de Parede",
|
|
||||||
"scripts.wallpapers.description": "Baixe e configure papéis de parede adicionais para sua área de trabalho.",
|
|
||||||
"scripts.copy": "Copiar",
|
|
||||||
"features.title": "O Que Está Incluído",
|
|
||||||
"features.packages.title": "Pacotes Essenciais",
|
|
||||||
"features.packages.description": "Codecs, firmware, fontes e utilitários para tornar seu sistema totalmente funcional.",
|
|
||||||
"features.customization.title": "Personalização GNOME",
|
|
||||||
"features.customization.description": "Extensões e ajustes para melhorar sua experiência com o desktop GNOME.",
|
|
||||||
"features.performance.title": "Desempenho",
|
|
||||||
"features.performance.description": "Otimizações de drivers e remoção de bloat para um sistema mais rápido.",
|
|
||||||
"footer.text": "Scripts de Pós-Instalação do Debian 12",
|
|
||||||
"footer.text2": "Desenvolvido por",
|
|
||||||
"footer.disclaimer": "Não afiliado ao Projeto Debian. Use por sua conta e risco.",
|
|
||||||
"notification.copied": "Copiado para a área de transferência!"
|
|
||||||
},
|
|
||||||
es: {
|
|
||||||
"title": "Scripts de Post-Instalación para Debian 12",
|
|
||||||
"hero.title": "Optimiza tu Experiencia con Debian 12 GNOME",
|
|
||||||
"hero.subtitle": "Una colección de scripts para personalizar y mejorar tu instalación de Debian 12 con aplicaciones esenciales, códecs, ajustes y más.",
|
|
||||||
"hero.download": "Descargar Debian 12",
|
|
||||||
"hero.viewScripts": "Ver Scripts",
|
|
||||||
"download.title": "Descargar Debian 12 GNOME",
|
|
||||||
"download.description": "Comienza con la ISO live oficial de Debian 12 GNOME para usar estos scripts de post-instalación.",
|
|
||||||
"download.button": "Descargar ISO",
|
|
||||||
"scripts.title": "Scripts de Post-Instalación",
|
|
||||||
"scripts.complete.title": "Post-Instalación Completa",
|
|
||||||
"scripts.complete.description": "Ejecuta todos los cambios recomendados incluyendo activación de repositorios, instalación de códecs, extensiones GNOME e instalación de aplicaciones.",
|
|
||||||
"scripts.repos.title": "Activar Repositorios",
|
|
||||||
"scripts.repos.description": "Activa los repositorios contrib y non-free e instala soporte para Flatpak con el repositorio Flathub.",
|
|
||||||
"scripts.firefox.title": "Firefox Actual",
|
|
||||||
"scripts.firefox.description": "Cambia de Firefox ESR a la versión de lanzamiento actual.",
|
|
||||||
"scripts.codecs.title": "Códecs & Ajustes",
|
|
||||||
"scripts.codecs.description": "Instala códecs multimedia, firmware, fuentes y utilidades útiles.",
|
|
||||||
"scripts.extensions.title": "Extensiones GNOME",
|
|
||||||
"scripts.extensions.description": "Instala extensiones útiles de GNOME como Dash-to-Dock, Tiling Assistant y más.",
|
|
||||||
"scripts.remove.title": "Eliminar Apps Innecesarios",
|
|
||||||
"scripts.remove.description": "Elimina aplicaciones preinstaladas innecesarias para limpiar tu sistema.",
|
|
||||||
"scripts.apps.title": "Instalar Aplicaciones",
|
|
||||||
"scripts.apps.description": "Instala aplicaciones útiles via Flatpak incluyendo GIMP, Inkscape y más.",
|
|
||||||
"scripts.radeon.title": "Radeon a AMDGPU",
|
|
||||||
"scripts.radeon.description": "Cambia del controlador Radeon a AMDGPU para mejor rendimiento con ciertas GPUs AMD.",
|
|
||||||
"scripts.fonts.title": "Instalar Fuentes",
|
|
||||||
"scripts.fonts.description": "Instala y configura fuentes adicionales para mejor tipografía.",
|
|
||||||
"scripts.wallpapers.title": "Instalar Fondos de Pantalla",
|
|
||||||
"scripts.wallpapers.description": "Descarga y configura fondos de pantalla adicionales para tu escritorio.",
|
|
||||||
"scripts.copy": "Copiar",
|
|
||||||
"features.title": "Qué está Incluido",
|
|
||||||
"features.packages.title": "Paquetes Esenciales",
|
|
||||||
"features.packages.description": "Códecs, firmware, fuentes y utilidades para hacer tu sistema completamente funcional.",
|
|
||||||
"features.customization.title": "Personalización GNOME",
|
|
||||||
"features.customization.description": "Extensiones y ajustes para mejorar tu experiencia con el escritorio GNOME.",
|
|
||||||
"features.performance.title": "Rendimiento",
|
|
||||||
"features.performance.description": "Optimizaciones de controladores y eliminación de bloat para un sistema más rápido.",
|
|
||||||
"footer.text": "Scripts de Post-Instalación para Debian 12",
|
|
||||||
"footer.text2": "Desarrollado por",
|
|
||||||
"footer.disclaimer": "No afiliado al Proyecto Debian. Úsalo bajo tu propio riesgo.",
|
|
||||||
"notification.copied": "¡Copiado al portapapeles!"
|
|
||||||
},
|
|
||||||
en: {
|
|
||||||
"title": "Debian 12 Post-Installation Scripts",
|
|
||||||
"hero.title": "Optimize Your Debian 12 GNOME Experience",
|
|
||||||
"hero.subtitle": "A collection of scripts to customize and enhance your Debian 12 installation with essential apps, codecs, tweaks, and more.",
|
|
||||||
"hero.download": "Download Debian 12",
|
|
||||||
"hero.viewScripts": "View Scripts",
|
|
||||||
"download.title": "Download Debian 12 GNOME",
|
|
||||||
"download.description": "Start with the official Debian 12 GNOME live ISO to use these post-installation scripts.",
|
|
||||||
"download.button": "Download ISO",
|
|
||||||
"scripts.title": "Post-Installation Scripts",
|
|
||||||
"scripts.complete.title": "Complete Post-Installation",
|
|
||||||
"scripts.complete.description": "Run all recommended changes including repository activation, codecs installation, GNOME extensions, and app installations.",
|
|
||||||
"scripts.repos.title": "Activate Repositories",
|
|
||||||
"scripts.repos.description": "Activate contrib and non-free repositories and install Flatpak support with Flathub.",
|
|
||||||
"scripts.firefox.title": "Firefox Current",
|
|
||||||
"scripts.firefox.description": "Change from Firefox ESR to the current release version.",
|
|
||||||
"scripts.codecs.title": "Codecs & Tweaks",
|
|
||||||
"scripts.codecs.description": "Install multimedia codecs, firmware, fonts, and useful utilities.",
|
|
||||||
"scripts.extensions.title": "GNOME Extensions",
|
|
||||||
"scripts.extensions.description": "Install useful GNOME extensions like Dash-to-Dock, Tiling Assistant, and more.",
|
|
||||||
"scripts.remove.title": "Remove Unneeded Apps",
|
|
||||||
"scripts.remove.description": "Remove unnecessary pre-installed applications to clean up your system.",
|
|
||||||
"scripts.apps.title": "Install Apps",
|
|
||||||
"scripts.apps.description": "Install useful applications via Flatpak including GIMP, Inkscape, and more.",
|
|
||||||
"scripts.radeon.title": "Radeon to AMDGPU",
|
|
||||||
"scripts.radeon.description": "Switch from Radeon to AMDGPU driver for better performance with certain AMD GPUs.",
|
|
||||||
"scripts.fonts.title": "Install Fonts",
|
|
||||||
"scripts.fonts.description": "Install and configure additional fonts for better typography.",
|
|
||||||
"scripts.wallpapers.title": "Install Wallpapers",
|
|
||||||
"scripts.wallpapers.description": "Download and set up additional wallpapers for your desktop.",
|
|
||||||
"scripts.copy": "Copy",
|
|
||||||
"features.title": "What's Included",
|
|
||||||
"features.packages.title": "Essential Packages",
|
|
||||||
"features.packages.description": "Codecs, firmware, fonts, and utilities to make your system fully functional.",
|
|
||||||
"features.customization.title": "GNOME Customization",
|
|
||||||
"features.customization.description": "Extensions and tweaks to enhance your GNOME desktop experience.",
|
|
||||||
"features.performance.title": "Performance",
|
|
||||||
"features.performance.description": "Driver optimizations and bloat removal for a faster system.",
|
|
||||||
"footer.text": "Debian 12 Post-Installation Scripts",
|
|
||||||
"footer.text2": "Developed by",
|
|
||||||
"footer.disclaimer": "Not affiliated with the Debian Project. Use at your own risk.",
|
|
||||||
"notification.copied": "Copied to clipboard!"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let currentLang = 'pt'; // Define a linguagem padrão
|
|
||||||
|
|
||||||
// Função para aplicar as traduções
|
|
||||||
function applyTranslations(lang) {
|
|
||||||
console.log('Aplicando traduções para:', lang); // Debug
|
|
||||||
|
|
||||||
if (!translations[lang]) {
|
|
||||||
console.error('Idioma não encontrado:', lang);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Seleciona todos os elementos com data-i18n
|
|
||||||
const elements = document.querySelectorAll('[data-i18n]');
|
|
||||||
console.log('Elementos encontrados:', elements.length); // Debug
|
|
||||||
|
|
||||||
elements.forEach(element => {
|
|
||||||
const key = element.getAttribute('data-i18n');
|
|
||||||
|
|
||||||
if (translations[lang][key]) {
|
|
||||||
// Trata diferentes tipos de elementos
|
|
||||||
if (element.tagName === 'INPUT' && element.type === 'submit') {
|
|
||||||
element.value = translations[lang][key];
|
|
||||||
} else if (element.tagName === 'INPUT' && element.hasAttribute('placeholder')) {
|
|
||||||
element.placeholder = translations[lang][key];
|
|
||||||
} else {
|
|
||||||
// Para elementos regulares, preserva HTML interno se necessário
|
|
||||||
if (element.innerHTML.includes('<')) {
|
|
||||||
// Se tem HTML interno, substitui apenas o texto
|
|
||||||
const tempDiv = document.createElement('div');
|
|
||||||
tempDiv.innerHTML = element.innerHTML;
|
|
||||||
|
|
||||||
// Encontra o nó de texto principal
|
|
||||||
const textNode = tempDiv.firstChild;
|
|
||||||
if (textNode && textNode.nodeType === Node.TEXT_NODE) {
|
|
||||||
textNode.textContent = translations[lang][key];
|
|
||||||
element.innerHTML = tempDiv.innerHTML;
|
|
||||||
} else {
|
|
||||||
// Se não encontrar nó de texto, substitui tudo
|
|
||||||
element.textContent = translations[lang][key];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
element.textContent = translations[lang][key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.warn('Chave de tradução não encontrada:', key, 'para idioma:', lang);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Atualiza o atributo lang do HTML
|
|
||||||
document.documentElement.lang = lang;
|
|
||||||
currentLang = lang;
|
|
||||||
|
|
||||||
console.log('Traduções aplicadas com sucesso para:', lang); // Debug
|
|
||||||
}
|
|
||||||
|
|
||||||
// Language switcher functionality
|
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
|
||||||
console.log('DOM carregado, inicializando sistema de idiomas'); // Debug
|
|
||||||
|
|
||||||
// Aplica as traduções iniciais
|
|
||||||
applyTranslations(currentLang);
|
|
||||||
|
|
||||||
const languageDropdownButton = document.getElementById('languageDropdownButton');
|
|
||||||
const languageDropdown = document.getElementById('languageDropdown');
|
|
||||||
|
|
||||||
if (!languageDropdownButton || !languageDropdown) {
|
|
||||||
console.error('Elementos do dropdown não encontrados');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle dropdown
|
|
||||||
languageDropdownButton.addEventListener('click', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
languageDropdown.classList.toggle('hidden');
|
|
||||||
console.log('Dropdown toggled'); // Debug
|
|
||||||
});
|
|
||||||
|
|
||||||
// Adiciona event listener para os links de idioma
|
|
||||||
const languageLinks = document.querySelectorAll('#languageDropdown a[data-lang]');
|
|
||||||
console.log('Links de idioma encontrados:', languageLinks.length); // Debug
|
|
||||||
|
|
||||||
languageLinks.forEach(link => {
|
|
||||||
link.addEventListener('click', function (event) {
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
const selectedLang = this.getAttribute('data-lang');
|
|
||||||
console.log('Idioma selecionado:', selectedLang); // Debug
|
|
||||||
|
|
||||||
if (selectedLang && selectedLang !== currentLang) {
|
|
||||||
applyTranslations(selectedLang);
|
|
||||||
|
|
||||||
// Feedback visual opcional
|
|
||||||
this.style.backgroundColor = '#f3f4f6';
|
|
||||||
setTimeout(() => {
|
|
||||||
this.style.backgroundColor = '';
|
|
||||||
}, 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
languageDropdown.classList.add('hidden');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Fecha dropdown ao clicar fora
|
|
||||||
document.addEventListener('click', function (event) {
|
|
||||||
if (!languageDropdownButton.contains(event.target) &&
|
|
||||||
!languageDropdown.contains(event.target)) {
|
|
||||||
languageDropdown.classList.add('hidden');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log('Sistema de idiomas inicializado com sucesso');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Copy to clipboard function (mantida como estava)
|
|
||||||
function copyToClipboard(id) {
|
|
||||||
const preElement = document.getElementById(id);
|
|
||||||
if (!preElement) {
|
|
||||||
console.error('Elemento não encontrado:', id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const textToCopy = preElement.textContent || preElement.innerText;
|
|
||||||
|
|
||||||
navigator.clipboard.writeText(textToCopy).then(() => {
|
|
||||||
const notification = document.getElementById('copyNotification');
|
|
||||||
if (notification) {
|
|
||||||
notification.classList.remove('hidden');
|
|
||||||
setTimeout(() => {
|
|
||||||
notification.classList.add('hidden');
|
|
||||||
}, 2000);
|
|
||||||
}
|
|
||||||
}).catch(err => {
|
|
||||||
console.error('Falha ao copiar texto:', err);
|
|
||||||
|
|
||||||
// Fallback para navegadores mais antigos
|
|
||||||
const textArea = document.createElement('textarea');
|
|
||||||
textArea.value = textToCopy;
|
|
||||||
document.body.appendChild(textArea);
|
|
||||||
textArea.focus();
|
|
||||||
textArea.select();
|
|
||||||
|
|
||||||
try {
|
|
||||||
document.execCommand('copy');
|
|
||||||
const notification = document.getElementById('copyNotification');
|
|
||||||
if (notification) {
|
|
||||||
notification.classList.remove('hidden');
|
|
||||||
setTimeout(() => {
|
|
||||||
notification.classList.add('hidden');
|
|
||||||
}, 2000);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Fallback de cópia também falhou:', err);
|
|
||||||
}
|
|
||||||
|
|
||||||
document.body.removeChild(textArea);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@ -1,7 +1,7 @@
|
|||||||
// Language translations
|
// Language translations
|
||||||
const translations = {
|
const translations = {
|
||||||
pt: {
|
pt: {
|
||||||
"title": "Scripts de Pós-Instalação do Debian 12",
|
"title": "Pós-Instalação do Debian 12",
|
||||||
"hero.title": "Otimize Sua Experiência com o Debian 12 GNOME",
|
"hero.title": "Otimize Sua Experiência com o Debian 12 GNOME",
|
||||||
"hero.subtitle": "Uma coleção de scripts para personalizar e melhorar sua instalação do Debian 12 com aplicativos essenciais, codecs, ajustes e muito mais.",
|
"hero.subtitle": "Uma coleção de scripts para personalizar e melhorar sua instalação do Debian 12 com aplicativos essenciais, codecs, ajustes e muito mais.",
|
||||||
"hero.download": "Baixar Debian 12",
|
"hero.download": "Baixar Debian 12",
|
||||||
@ -39,11 +39,12 @@ const translations = {
|
|||||||
"features.performance.title": "Desempenho",
|
"features.performance.title": "Desempenho",
|
||||||
"features.performance.description": "Otimizações de drivers e remoção de bloat para um sistema mais rápido.",
|
"features.performance.description": "Otimizações de drivers e remoção de bloat para um sistema mais rápido.",
|
||||||
"footer.text": "Scripts de Pós-Instalação do Debian 12",
|
"footer.text": "Scripts de Pós-Instalação do Debian 12",
|
||||||
|
"footer.text2": "Desenvolvido por",
|
||||||
"footer.disclaimer": "Não afiliado ao Projeto Debian. Use por sua conta e risco.",
|
"footer.disclaimer": "Não afiliado ao Projeto Debian. Use por sua conta e risco.",
|
||||||
"notification.copied": "Copiado para a área de transferência!"
|
"notification.copied": "Copiado para a área de transferência!"
|
||||||
},
|
},
|
||||||
es: {
|
es: {
|
||||||
"title": "Scripts de Post-Instalación para Debian 12",
|
"title": "Post-Instalación para Debian 12",
|
||||||
"hero.title": "Optimiza tu Experiencia con Debian 12 GNOME",
|
"hero.title": "Optimiza tu Experiencia con Debian 12 GNOME",
|
||||||
"hero.subtitle": "Una colección de scripts para personalizar y mejorar tu instalación de Debian 12 con aplicaciones esenciales, códecs, ajustes y más.",
|
"hero.subtitle": "Una colección de scripts para personalizar y mejorar tu instalación de Debian 12 con aplicaciones esenciales, códecs, ajustes y más.",
|
||||||
"hero.download": "Descargar Debian 12",
|
"hero.download": "Descargar Debian 12",
|
||||||
@ -81,11 +82,12 @@ const translations = {
|
|||||||
"features.performance.title": "Rendimiento",
|
"features.performance.title": "Rendimiento",
|
||||||
"features.performance.description": "Optimizaciones de controladores y eliminación de bloat para un sistema más rápido.",
|
"features.performance.description": "Optimizaciones de controladores y eliminación de bloat para un sistema más rápido.",
|
||||||
"footer.text": "Scripts de Post-Instalación para Debian 12",
|
"footer.text": "Scripts de Post-Instalación para Debian 12",
|
||||||
|
"footer.text2": "Desarrollado por",
|
||||||
"footer.disclaimer": "No afiliado al Proyecto Debian. Úsalo bajo tu propio riesgo.",
|
"footer.disclaimer": "No afiliado al Proyecto Debian. Úsalo bajo tu propio riesgo.",
|
||||||
"notification.copied": "¡Copiado al portapapeles!"
|
"notification.copied": "¡Copiado al portapapeles!"
|
||||||
},
|
},
|
||||||
en: {
|
en: {
|
||||||
"title": "Debian 12 Post-Installation Scripts",
|
"title": "Debian 12 Post-Installation",
|
||||||
"hero.title": "Optimize Your Debian 12 GNOME Experience",
|
"hero.title": "Optimize Your Debian 12 GNOME Experience",
|
||||||
"hero.subtitle": "A collection of scripts to customize and enhance your Debian 12 installation with essential apps, codecs, tweaks, and more.",
|
"hero.subtitle": "A collection of scripts to customize and enhance your Debian 12 installation with essential apps, codecs, tweaks, and more.",
|
||||||
"hero.download": "Download Debian 12",
|
"hero.download": "Download Debian 12",
|
||||||
@ -123,65 +125,168 @@ const translations = {
|
|||||||
"features.performance.title": "Performance",
|
"features.performance.title": "Performance",
|
||||||
"features.performance.description": "Driver optimizations and bloat removal for a faster system.",
|
"features.performance.description": "Driver optimizations and bloat removal for a faster system.",
|
||||||
"footer.text": "Debian 12 Post-Installation Scripts",
|
"footer.text": "Debian 12 Post-Installation Scripts",
|
||||||
|
"footer.text2": "Developed by",
|
||||||
"footer.disclaimer": "Not affiliated with the Debian Project. Use at your own risk.",
|
"footer.disclaimer": "Not affiliated with the Debian Project. Use at your own risk.",
|
||||||
"notification.copied": "Copied to clipboard!"
|
"notification.copied": "Copied to clipboard!"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let currentLang = 'pt'; // Define a linguagem padrão
|
||||||
|
|
||||||
|
// Função para aplicar as traduções
|
||||||
|
function applyTranslations(lang) {
|
||||||
|
console.log('Aplicando traduções para:', lang); // Debug
|
||||||
|
|
||||||
|
if (!translations[lang]) {
|
||||||
|
console.error('Idioma não encontrado:', lang);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Seleciona todos os elementos com data-i18n
|
||||||
|
const elements = document.querySelectorAll('[data-i18n]');
|
||||||
|
console.log('Elementos encontrados:', elements.length); // Debug
|
||||||
|
|
||||||
|
elements.forEach(element => {
|
||||||
|
const key = element.getAttribute('data-i18n');
|
||||||
|
|
||||||
|
if (translations[lang][key]) {
|
||||||
|
// Trata diferentes tipos de elementos
|
||||||
|
if (element.tagName === 'INPUT' && element.type === 'submit') {
|
||||||
|
element.value = translations[lang][key];
|
||||||
|
} else if (element.tagName === 'INPUT' && element.hasAttribute('placeholder')) {
|
||||||
|
element.placeholder = translations[lang][key];
|
||||||
|
} else {
|
||||||
|
// Para elementos regulares, preserva HTML interno se necessário
|
||||||
|
if (element.innerHTML.includes('<')) {
|
||||||
|
// Se tem HTML interno, substitui apenas o texto
|
||||||
|
const tempDiv = document.createElement('div');
|
||||||
|
tempDiv.innerHTML = element.innerHTML;
|
||||||
|
|
||||||
|
// Encontra o nó de texto principal
|
||||||
|
const textNode = tempDiv.firstChild;
|
||||||
|
if (textNode && textNode.nodeType === Node.TEXT_NODE) {
|
||||||
|
textNode.textContent = translations[lang][key];
|
||||||
|
element.innerHTML = tempDiv.innerHTML;
|
||||||
|
} else {
|
||||||
|
// Se não encontrar nó de texto, substitui tudo
|
||||||
|
element.textContent = translations[lang][key];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
element.textContent = translations[lang][key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.warn('Chave de tradução não encontrada:', key, 'para idioma:', lang);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Atualiza o atributo lang do HTML
|
||||||
|
document.documentElement.lang = lang;
|
||||||
|
currentLang = lang;
|
||||||
|
|
||||||
|
console.log('Traduções aplicadas com sucesso para:', lang); // Debug
|
||||||
|
}
|
||||||
|
|
||||||
// Language switcher functionality
|
// Language switcher functionality
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
// Language dropdown toggle
|
console.log('DOM carregado, inicializando sistema de idiomas'); // Debug
|
||||||
|
|
||||||
|
// Aplica as traduções iniciais
|
||||||
|
applyTranslations(currentLang);
|
||||||
|
|
||||||
const languageDropdownButton = document.getElementById('languageDropdownButton');
|
const languageDropdownButton = document.getElementById('languageDropdownButton');
|
||||||
const languageDropdown = document.getElementById('languageDropdown');
|
const languageDropdown = document.getElementById('languageDropdown');
|
||||||
|
|
||||||
languageDropdownButton.addEventListener('click', function () {
|
if (!languageDropdownButton || !languageDropdown) {
|
||||||
|
console.error('Elementos do dropdown não encontrados');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle dropdown
|
||||||
|
languageDropdownButton.addEventListener('click', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
languageDropdown.classList.toggle('hidden');
|
languageDropdown.classList.toggle('hidden');
|
||||||
|
console.log('Dropdown toggled'); // Debug
|
||||||
});
|
});
|
||||||
|
|
||||||
// Close dropdown when clicking outside
|
// Adiciona event listener para os links de idioma
|
||||||
|
const languageLinks = document.querySelectorAll('#languageDropdown a[data-lang]');
|
||||||
|
console.log('Links de idioma encontrados:', languageLinks.length); // Debug
|
||||||
|
|
||||||
|
languageLinks.forEach(link => {
|
||||||
|
link.addEventListener('click', function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
const selectedLang = this.getAttribute('data-lang');
|
||||||
|
console.log('Idioma selecionado:', selectedLang); // Debug
|
||||||
|
|
||||||
|
if (selectedLang && selectedLang !== currentLang) {
|
||||||
|
applyTranslations(selectedLang);
|
||||||
|
|
||||||
|
// Feedback visual opcional
|
||||||
|
this.style.backgroundColor = '#f3f4f6';
|
||||||
|
setTimeout(() => {
|
||||||
|
this.style.backgroundColor = '';
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
languageDropdown.classList.add('hidden');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fecha dropdown ao clicar fora
|
||||||
document.addEventListener('click', function (event) {
|
document.addEventListener('click', function (event) {
|
||||||
if (!languageDropdownButton.contains(event.target) && !languageDropdown.contains(event.target)) {
|
if (!languageDropdownButton.contains(event.target) &&
|
||||||
|
!languageDropdown.contains(event.target)) {
|
||||||
languageDropdown.classList.add('hidden');
|
languageDropdown.classList.add('hidden');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Language selection
|
console.log('Sistema de idiomas inicializado com sucesso');
|
||||||
languageDropdown.querySelectorAll('a').forEach(link => {
|
|
||||||
link.addEventListener('click', function (event) {
|
|
||||||
event.preventDefault();
|
|
||||||
const selectedLang = this.dataset.lang;
|
|
||||||
setLanguage(selectedLang);
|
|
||||||
languageDropdown.classList.add('hidden');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Set language
|
|
||||||
function setLanguage(lang) {
|
|
||||||
document.querySelectorAll('[data-i18n]').forEach(element => {
|
|
||||||
const key = element.dataset.i18n;
|
|
||||||
if (translations[lang] && translations[lang][key]) {
|
|
||||||
element.textContent = translations[lang][key];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Como agora é apenas um ícone, não precisamos atualizar o texto do botão
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set initial language (you might want to store this in localStorage)
|
|
||||||
setLanguage('pt');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Copy to clipboard functionality
|
// Copy to clipboard function (mantida como estava)
|
||||||
function copyToClipboard(id) {
|
function copyToClipboard(id) {
|
||||||
const codeElement = document.getElementById(id);
|
const preElement = document.getElementById(id);
|
||||||
const textToCopy = codeElement.textContent || codeElement.innerText;
|
if (!preElement) {
|
||||||
|
console.error('Elemento não encontrado:', id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const textToCopy = preElement.textContent || preElement.innerText;
|
||||||
|
|
||||||
navigator.clipboard.writeText(textToCopy).then(() => {
|
navigator.clipboard.writeText(textToCopy).then(() => {
|
||||||
const notification = document.getElementById('copyNotification');
|
const notification = document.getElementById('copyNotification');
|
||||||
notification.classList.remove('hidden');
|
if (notification) {
|
||||||
setTimeout(() => {
|
notification.classList.remove('hidden');
|
||||||
notification.classList.add('hidden');
|
setTimeout(() => {
|
||||||
}, 2000);
|
notification.classList.add('hidden');
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.error('Erro ao copiar: ', err);
|
console.error('Falha ao copiar texto:', err);
|
||||||
|
|
||||||
|
// Fallback para navegadores mais antigos
|
||||||
|
const textArea = document.createElement('textarea');
|
||||||
|
textArea.value = textToCopy;
|
||||||
|
document.body.appendChild(textArea);
|
||||||
|
textArea.focus();
|
||||||
|
textArea.select();
|
||||||
|
|
||||||
|
try {
|
||||||
|
document.execCommand('copy');
|
||||||
|
const notification = document.getElementById('copyNotification');
|
||||||
|
if (notification) {
|
||||||
|
notification.classList.remove('hidden');
|
||||||
|
setTimeout(() => {
|
||||||
|
notification.classList.add('hidden');
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Fallback de cópia também falhou:', err);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.body.removeChild(textArea);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user