diff --git a/slips/static/slips/css/style.css b/slips/static/slips/css/style.css index 92e555a..3ba845a 100644 --- a/slips/static/slips/css/style.css +++ b/slips/static/slips/css/style.css @@ -137,6 +137,20 @@ html[lang="fa"] body { gap: 0.5rem; } +.lang-label { + display: inline-flex; + align-items: center; + gap: 0.35rem; +} + +.lang-flag { + width: 1.15em; + height: 0.85em; + border-radius: 2px; + box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); + flex-shrink: 0; +} + /* Layout */ .main-content { max-width: 1200px; diff --git a/slips/static/slips/js/i18n.js b/slips/static/slips/js/i18n.js index 9f939d3..dc0e8dc 100644 --- a/slips/static/slips/js/i18n.js +++ b/slips/static/slips/js/i18n.js @@ -83,9 +83,15 @@ const translations = { } }; -let currentLang = localStorage.getItem('slip_lang') || 'en'; +let currentLang = localStorage.getItem('slip_lang') || 'fa'; let currentTheme = localStorage.getItem('slip_theme') || 'light'; +// SVG flags: Windows often cannot render flag emojis (shows "IR"/"GB" instead) +const FLAG_SVG = { + fa: '', + en: '', +}; + function applyTheme(theme) { document.documentElement.setAttribute('data-theme', theme); const label = document.getElementById('theme-label'); @@ -111,10 +117,12 @@ function applyLanguage(lang) { el.textContent = translations[lang][key]; } }); - + + // Button shows the language you can switch to const toggleBtn = document.getElementById('lang-label'); if (toggleBtn) { - toggleBtn.textContent = lang === 'en' ? '🇮🇷 FA' : '🇬🇧 EN'; + const next = lang === 'en' ? 'fa' : 'en'; + toggleBtn.innerHTML = FLAG_SVG[next] + ' ' + next.toUpperCase(); } if (typeof window.updateLabelsPreview === 'function') { diff --git a/slips/templates/slips/base.html b/slips/templates/slips/base.html index 5c13e33..05df980 100644 --- a/slips/templates/slips/base.html +++ b/slips/templates/slips/base.html @@ -1,10 +1,10 @@ {% load static %} - +
-