Default to Persian and use SVG language flags (#11)

Co-authored-by: Cursor <cursoragent@cursor.com>
Reviewed-on: #11
Co-authored-by: diaco <dyaco8464@yahoo.com>
Co-committed-by: diaco <dyaco8464@yahoo.com>
This commit was merged in pull request #11.
This commit is contained in:
2026-10-04 07:31:59 +00:00
committed by rhino
parent cb8fd593c0
commit bf5ce1bb3f
3 changed files with 39 additions and 11 deletions

View File

@@ -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;

View File

@@ -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: '<svg class="lang-flag" viewBox="0 0 9 6" aria-hidden="true"><rect width="9" height="2" fill="#239f40"/><rect y="2" width="9" height="2" fill="#fff"/><rect y="4" width="9" height="2" fill="#da0000"/></svg>',
en: '<svg class="lang-flag" viewBox="0 0 60 30" aria-hidden="true"><rect width="60" height="30" fill="#012169"/><path d="M0,0 60,30M60,0 0,30" stroke="#fff" stroke-width="6"/><path d="M0,0 60,30M60,0 0,30" stroke="#C8102E" stroke-width="2"/><path d="M30,0v30M0,15h60" stroke="#fff" stroke-width="10"/><path d="M30,0v30M0,15h60" stroke="#C8102E" stroke-width="6"/></svg>',
};
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') {