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:
@@ -318,6 +318,7 @@ input:focus, select:focus {
|
|||||||
.badge {
|
.badge {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
gap: 0.25em;
|
||||||
padding: 0.25rem 0.75rem;
|
padding: 0.25rem 0.75rem;
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
@@ -451,6 +452,13 @@ input:focus, select:focus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* RTL Support for Persian */
|
/* RTL Support for Persian */
|
||||||
html[dir="rtl"] {
|
html[dir="rtl"] .toast {
|
||||||
/* Kept LTR as requested by user, but framework is ready if they change their mind */
|
right: auto;
|
||||||
|
left: 2rem;
|
||||||
|
border-left: none;
|
||||||
|
border-right: 4px solid var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
html[dir="rtl"] .toast.error {
|
||||||
|
border-right-color: var(--danger);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,9 +39,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
const bc = Math.ceil(cc / cpb);
|
const bc = Math.ceil(cc / cpb);
|
||||||
const bp = Math.ceil(bc / 4);
|
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
|
// Listeners for updates
|
||||||
totalWeightInput.addEventListener('input', updatePreview);
|
totalWeightInput.addEventListener('input', updatePreview);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ const translations = {
|
|||||||
'canisters_unit': 'Canisters',
|
'canisters_unit': 'Canisters',
|
||||||
'boxes_unit': 'Boxes',
|
'boxes_unit': 'Boxes',
|
||||||
'pages_unit': 'Page(s)',
|
'pages_unit': 'Page(s)',
|
||||||
|
'preview_pages': 'pages',
|
||||||
'pages_needed': 'Pages Needed',
|
'pages_needed': 'Pages Needed',
|
||||||
'total_pages': 'Pages',
|
'total_pages': 'Pages',
|
||||||
'status_pending': 'Pending',
|
'status_pending': 'Pending',
|
||||||
@@ -65,6 +66,7 @@ const translations = {
|
|||||||
'canisters_unit': 'گالن',
|
'canisters_unit': 'گالن',
|
||||||
'boxes_unit': 'کارتن',
|
'boxes_unit': 'کارتن',
|
||||||
'pages_unit': 'صفحه',
|
'pages_unit': 'صفحه',
|
||||||
|
'preview_pages': 'صفحه',
|
||||||
'pages_needed': 'تعداد صفحات',
|
'pages_needed': 'تعداد صفحات',
|
||||||
'total_pages': 'صفحات',
|
'total_pages': 'صفحات',
|
||||||
'status_pending': 'در انتظار',
|
'status_pending': 'در انتظار',
|
||||||
@@ -85,6 +87,7 @@ let currentLang = localStorage.getItem('slip_lang') || 'en';
|
|||||||
|
|
||||||
function applyLanguage(lang) {
|
function applyLanguage(lang) {
|
||||||
document.documentElement.lang = lang;
|
document.documentElement.lang = lang;
|
||||||
|
document.documentElement.dir = lang === 'fa' ? 'rtl' : 'ltr';
|
||||||
|
|
||||||
document.querySelectorAll('[data-i18n]').forEach(el => {
|
document.querySelectorAll('[data-i18n]').forEach(el => {
|
||||||
const key = el.getAttribute('data-i18n');
|
const key = el.getAttribute('data-i18n');
|
||||||
@@ -97,9 +100,10 @@ function applyLanguage(lang) {
|
|||||||
if (toggleBtn) {
|
if (toggleBtn) {
|
||||||
toggleBtn.textContent = lang === 'en' ? '🇮🇷 FA' : '🇬🇧 EN';
|
toggleBtn.textContent = lang === 'en' ? '🇮🇷 FA' : '🇬🇧 EN';
|
||||||
}
|
}
|
||||||
|
|
||||||
// User requested Persian to be LTR, so we don't change the dir attribute
|
if (typeof window.updateLabelsPreview === 'function') {
|
||||||
// document.documentElement.dir = lang === 'fa' ? 'rtl' : 'ltr';
|
window.updateLabelsPreview();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleLanguage() {
|
function toggleLanguage() {
|
||||||
|
|||||||
Reference in New Issue
Block a user