Files
MyWebsite/public/scripts/language-toggle.js
T
Itziar Zameza García 476dd54c0e feat: initial portfolio implementation with dark mode and i18n
- Add Astro portfolio with TypeScript
- Implement dark/light theme toggle
- Add Spanish/English translations
- Create under construction page
- Style with Tailwind CSS and glassmorphism effects
- Add profile image, projects, skills, and experience sections
2026-03-14 22:41:48 +01:00

21 lines
577 B
JavaScript

(function () {
const savedLang = localStorage.getItem("language") || "en";
const htmlLang = document.documentElement.lang || "en";
const currentLang = savedLang || htmlLang;
window.setLanguage = function (lang) {
localStorage.setItem("language", lang);
location.reload();
};
window.getCurrentLanguage = function () {
return localStorage.getItem("language") || "en";
};
window.toggleLanguage = function () {
const currentLang = getCurrentLanguage();
const newLang = currentLang === "en" ? "es" : "en";
setLanguage(newLang);
};
})();