diff --git a/html/js/app.js b/html/js/app.js index eb98fef..a9913c7 100644 --- a/html/js/app.js +++ b/html/js/app.js @@ -27,14 +27,20 @@ function toggleLang() { currentLang = currentLang === 'en' ? 'ru' : 'en'; const t = translations[currentLang]; - document.getElementById('title').textContent = t.title; - document.getElementById('desc').textContent = t.desc; - document.getElementById('button').textContent = t.button; - document.getElementById('aboutTitle').textContent = t.aboutTitle; - document.getElementById('aboutText').textContent = t.aboutText; - document.getElementById('projectsTitle').textContent = t.projectsTitle; - document.getElementById('contactTitle').textContent = t.contactTitle; - document.getElementById('contactText').textContent = t.contactText; + tryToggleTextContent('title', t.title); + tryToggleTextContent('desc', t.desc); + tryToggleTextContent('button', t.button); + tryToggleTextContent('aboutTitle', t.aboutTitle); + tryToggleTextContent('aboutText', t.aboutText); + tryToggleTextContent('projectsTitle', t.projectsTitle); + tryToggleTextContent('contactTitle', t.contactTitle); + tryToggleTextContent('contactText', t.contactText); +} + +function tryToggleTextContent(elementId, textContent) { + let el = document.getElementById(elementId); + if (el != null) + el.textContent = textContent; } // Background animation