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:
2026-10-01 19:47:50 +00:00
committed by rhino
parent 0aa04301e4
commit 0c1340cf3e
3 changed files with 22 additions and 7 deletions

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() {