| |
| const translations = { |
| uz: { |
| home: "🏠 Bosh sahifa", |
| trending: "🔥 Trenddagilar", |
| favorites: "💖 Sevimlilar", |
| genres: "🎭 Janrlar", |
| new: "🌟 Yangi", |
| contact: "📞 Aloqa", |
| popular: "🔥 Mashhur animelar", |
| watch: "Ko‘rish", |
| rights: "Barcha huquqlar himoyalangan" |
| }, |
| en: { |
| home: "🏠 Home", |
| trending: "🔥 Trending", |
| favorites: "💖 Favorites", |
| genres: "🎭 Genres", |
| new: "🌟 New", |
| contact: "📞 Contact", |
| popular: "🔥 Popular Anime", |
| watch: "Watch", |
| rights: "All rights reserved" |
| }, |
| ru: { |
| home: "🏠 Главная", |
| trending: "🔥 В тренде", |
| favorites: "💖 Избранное", |
| genres: "🎭 Жанры", |
| new: "🌟 Новые", |
| contact: "📞 Контакт", |
| popular: "🔥 Популярные аниме", |
| watch: "Смотреть", |
| rights: "Все права защищены" |
| } |
| }; |
|
|
| |
| const languageSelect = document.getElementById("language"); |
| const elements = document.querySelectorAll("[data-key]"); |
|
|
| |
| const savedLang = localStorage.getItem("lang") || "uz"; |
| languageSelect.value = savedLang; |
| changeLanguage(savedLang); |
|
|
| |
| languageSelect.addEventListener("change", (e) => { |
| const lang = e.target.value; |
| changeLanguage(lang); |
| localStorage.setItem("lang", lang); |
| }); |
|
|
| |
| function changeLanguage(lang) { |
| elements.forEach((el) => { |
| const key = el.getAttribute("data-key"); |
| if (translations[lang][key]) { |
| el.textContent = translations[lang][key]; |
| } |
| }); |
| } |
|
|
| |
| const watchButtons = document.querySelectorAll("button[data-key='watch']"); |
| watchButtons.forEach((btn) => { |
| btn.addEventListener("click", () => { |
| btn.textContent = "▶️ Boshlanmoqda..."; |
| btn.disabled = true; |
| setTimeout(() => { |
| btn.textContent = translations[languageSelect.value].watch; |
| btn.disabled = false; |
| }, 2000); |
| }); |
| }); |