Исправил переключение языка

This commit is contained in:
RedGrox
2026-05-19 20:40:57 +03:00
parent 9b94dbcbe7
commit 9b094fcfe7
+14 -8
View File
@@ -27,14 +27,20 @@ function toggleLang() {
currentLang = currentLang === 'en' ? 'ru' : 'en'; currentLang = currentLang === 'en' ? 'ru' : 'en';
const t = translations[currentLang]; const t = translations[currentLang];
document.getElementById('title').textContent = t.title; tryToggleTextContent('title', t.title);
document.getElementById('desc').textContent = t.desc; tryToggleTextContent('desc', t.desc);
document.getElementById('button').textContent = t.button; tryToggleTextContent('button', t.button);
document.getElementById('aboutTitle').textContent = t.aboutTitle; tryToggleTextContent('aboutTitle', t.aboutTitle);
document.getElementById('aboutText').textContent = t.aboutText; tryToggleTextContent('aboutText', t.aboutText);
document.getElementById('projectsTitle').textContent = t.projectsTitle; tryToggleTextContent('projectsTitle', t.projectsTitle);
document.getElementById('contactTitle').textContent = t.contactTitle; tryToggleTextContent('contactTitle', t.contactTitle);
document.getElementById('contactText').textContent = t.contactText; tryToggleTextContent('contactText', t.contactText);
}
function tryToggleTextContent(elementId, textContent) {
let el = document.getElementById(elementId);
if (el != null)
el.textContent = textContent;
} }
// Background animation // Background animation