Localize labels preview and enable Persian RTL.

Translate the data-entry preview line, space badge units correctly, and set dir=rtl for FA.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-01 23:13:20 +03:30
parent 0aa04301e4
commit dba99d01d1
3 changed files with 22 additions and 7 deletions

View File

@@ -318,6 +318,7 @@ input:focus, select:focus {
.badge {
display: inline-flex;
align-items: center;
gap: 0.25em;
padding: 0.25rem 0.75rem;
border-radius: 999px;
font-size: 0.75rem;
@@ -451,6 +452,13 @@ input:focus, select:focus {
}
/* RTL Support for Persian */
html[dir="rtl"] {
/* Kept LTR as requested by user, but framework is ready if they change their mind */
html[dir="rtl"] .toast {
right: auto;
left: 2rem;
border-left: none;
border-right: 4px solid var(--accent);
}
html[dir="rtl"] .toast.error {
border-right-color: var(--danger);
}

View File

@@ -39,9 +39,12 @@ document.addEventListener('DOMContentLoaded', () => {
const bc = Math.ceil(cc / cpb);
const bp = Math.ceil(bc / 4);
previewDisplay.textContent = `Canisters: ${cc} (${cp} pages) | Boxes: ${bc} (${bp} pages)`;
const t = translations[currentLang] || translations.en;
previewDisplay.textContent =
`${t.canisters_unit}: ${cc} (${cp} ${t.preview_pages}) | ${t.boxes_unit}: ${bc} (${bp} ${t.preview_pages})`;
}
window.updateLabelsPreview = updatePreview;
// Listeners for updates
totalWeightInput.addEventListener('input', updatePreview);

View File

@@ -25,6 +25,7 @@ const translations = {
'canisters_unit': 'Canisters',
'boxes_unit': 'Boxes',
'pages_unit': 'Page(s)',
'preview_pages': 'pages',
'pages_needed': 'Pages Needed',
'total_pages': 'Pages',
'status_pending': 'Pending',
@@ -65,6 +66,7 @@ const translations = {
'canisters_unit': 'گالن',
'boxes_unit': 'کارتن',
'pages_unit': 'صفحه',
'preview_pages': 'صفحه',
'pages_needed': 'تعداد صفحات',
'total_pages': 'صفحات',
'status_pending': 'در انتظار',
@@ -85,6 +87,7 @@ let currentLang = localStorage.getItem('slip_lang') || 'en';
function applyLanguage(lang) {
document.documentElement.lang = lang;
document.documentElement.dir = lang === 'fa' ? 'rtl' : 'ltr';
document.querySelectorAll('[data-i18n]').forEach(el => {
const key = el.getAttribute('data-i18n');
@@ -97,9 +100,10 @@ function applyLanguage(lang) {
if (toggleBtn) {
toggleBtn.textContent = lang === 'en' ? '🇮🇷 FA' : '🇬🇧 EN';
}
// User requested Persian to be LTR, so we don't change the dir attribute
// document.documentElement.dir = lang === 'fa' ? 'rtl' : 'ltr';
if (typeof window.updateLabelsPreview === 'function') {
window.updateLabelsPreview();
}
}
function toggleLanguage() {