Localize labels preview and enable Persian RTL (#7)
## Summary - Translate Data Entry labels preview when language is Persian - Enable `dir=rtl` for FA (toast position mirrored) - Add badge `gap` so page counts show as `4 Page(s)` not `4Page(s)` ## Test plan - [ ] Data Entry in FA shows e.g. `گالن: 20 (5 صفحه) | کارتن: 5 (2 صفحه)` - [ ] Toggling language refreshes the preview line - [ ] Print Queue badges have space before Page(s)/صفحه - [ ] FA layout is RTL Reviewed-on: #7 Co-authored-by: Diaco Soltanpour <dyaco8464@yahoo.com> Co-committed-by: Diaco Soltanpour <dyaco8464@yahoo.com>
This commit was merged in pull request #7.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user