Default to Persian and use SVG language flags #11
@@ -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;
|
||||
|
||||
@@ -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') {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr">
|
||||
<html lang="fa" dir="rtl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}Lithium | Print Label{% endblock %}</title>
|
||||
<title>{% block title %}لیتیوم | پرینت لیبل{% endblock %}</title>
|
||||
<link rel="icon" href="{% static 'lithium.png' %}" type="image/png">
|
||||
<link rel="apple-touch-icon" href="{% static 'lithium.png' %}">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
@@ -15,6 +15,9 @@
|
||||
(function () {
|
||||
var t = localStorage.getItem('slip_theme') || 'light';
|
||||
document.documentElement.setAttribute('data-theme', t);
|
||||
var lang = localStorage.getItem('slip_lang') || 'fa';
|
||||
document.documentElement.lang = lang;
|
||||
document.documentElement.dir = lang === 'fa' ? 'rtl' : 'ltr';
|
||||
})();
|
||||
</script>
|
||||
{% block extra_head %}{% endblock %}
|
||||
@@ -24,19 +27,22 @@
|
||||
<div class="nav-container">
|
||||
<a href="{% url 'entry' %}" class="nav-logo">
|
||||
<img class="logo-icon" src="{% static 'lithium.png' %}" alt="" width="32" height="32">
|
||||
<span class="logo-text" data-i18n="app_title">Lithium | Print Label</span>
|
||||
<span class="logo-text" data-i18n="app_title">لیتیوم | پرینت لیبل</span>
|
||||
</a>
|
||||
<div class="nav-links">
|
||||
<a href="{% url 'entry' %}" class="nav-link {% block nav_entry_active %}{% endblock %}" data-i18n="data_entry">Data Entry</a>
|
||||
<a href="{% url 'print_queue' %}" class="nav-link {% block nav_print_active %}{% endblock %}" data-i18n="print_queue">Print Queue</a>
|
||||
<a href="{% url 'calibrate' %}" class="nav-link" data-i18n="calibrate">Calibrate</a>
|
||||
<a href="{% url 'entry' %}" class="nav-link {% block nav_entry_active %}{% endblock %}" data-i18n="data_entry">ثبت اطلاعات</a>
|
||||
<a href="{% url 'print_queue' %}" class="nav-link {% block nav_print_active %}{% endblock %}" data-i18n="print_queue">صف چاپ</a>
|
||||
<a href="{% url 'calibrate' %}" class="nav-link" data-i18n="calibrate">کالیبراسیون</a>
|
||||
</div>
|
||||
<div class="nav-actions">
|
||||
<button id="theme-toggle" class="btn btn-ghost" type="button" onclick="toggleTheme()" aria-label="Toggle theme">
|
||||
<span id="theme-label">🌙</span>
|
||||
</button>
|
||||
<button id="lang-toggle" class="btn btn-ghost" type="button" onclick="toggleLanguage()">
|
||||
<span id="lang-label">🇬🇧 EN</span>
|
||||
<button id="lang-toggle" class="btn btn-ghost" type="button" onclick="toggleLanguage()" aria-label="Toggle language">
|
||||
<span id="lang-label" class="lang-label">
|
||||
<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>
|
||||
EN
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user