diff --git a/assets/js/app.js b/assets/js/app.js index c363095..e09f7c0 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -321,7 +321,7 @@ function _scaleAutoFillUse(msg) { if (scaleAlreadyMl) { const density = _scaleDensityForProduct(currentProduct); val = Math.round(grams * density); - if (density !== 1.00) hintExtra = ` (densità ${density} g/ml)`; + if (density !== 1.00) hintExtra = ' ' + t('scale.density_hint', { density }); } else { val = Math.round(grams); } @@ -331,7 +331,7 @@ function _scaleAutoFillUse(msg) { } else { const density = _scaleDensityForProduct(currentProduct); val = Math.round(grams / density); - if (density !== 1.00) hintExtra = ` (densità ${density} g/ml)`; + if (density !== 1.00) hintExtra = ' ' + t('scale.density_hint', { density }); } } @@ -407,7 +407,7 @@ function _scaleAutoFillRecipeUse(msg) { if (scaleAlreadyMl) { const density = _scaleDensityForProduct(currentProduct); val = Math.round(grams * density); - if (density !== 1.00) hintExtra = ` (densità ${density} g/ml)`; + if (density !== 1.00) hintExtra = ' ' + t('scale.density_hint', { density }); } else { val = Math.round(grams); } @@ -417,7 +417,7 @@ function _scaleAutoFillRecipeUse(msg) { } else { const density = _scaleDensityForProduct(currentProduct); val = Math.round(grams / density); - if (density !== 1.00) hintExtra = ` (densità ${density} g/ml)`; + if (density !== 1.00) hintExtra = ' ' + t('scale.density_hint', { density }); } } @@ -434,21 +434,21 @@ function _scaleAutoFillRecipeUse(msg) { livVal.textContent = `${msg.value} ${msg.unit || 'kg'}`; } } - if (livStatus) livStatus.textContent = msg.stable ? '✓ Stabile' : '…'; + if (livStatus) livStatus.textContent = msg.stable ? t('scale.stable') : '…'; // Update live hint in modal with the raw scale reading always const hint = document.getElementById('ruse-scale-hint'); if (hint) { hint.textContent = `⚖️ Bilancia: ${msg.value} ${msg.unit || 'kg'}${msg.stable ? ' ✓' : ' …'}`; if (unit === 'ml' && srcUnit !== 'ml') { - hint.textContent += ' (verrà convertito in ml)'; + hint.textContent += ' ' + t('scale.ml_hint'); } hint.style.display = ''; } if (val < 10) { _cancelScaleStabilityWait(); // stop bar only; keep sentinel - if (livLabel) livLabel.textContent = 'Peso troppo basso — attendi…'; + if (livLabel) livLabel.textContent = t('scale.weight_too_low'); return; } @@ -461,7 +461,7 @@ function _scaleAutoFillRecipeUse(msg) { _scaleStabilityVal = val; _scaleUserDismissed = false; _cancelScaleTimersOnly(); - if (livLabel) livLabel.textContent = 'Peso rilevato — attendi 10s di stabilità…'; + if (livLabel) livLabel.textContent = t('scale.weight_detected'); // Hide confirm bar when new value arrives const confirmWrap = document.getElementById('ruse-scale-confirm-wrap'); if (confirmWrap) confirmWrap.style.display = 'none'; @@ -472,7 +472,7 @@ function _scaleAutoFillRecipeUse(msg) { hint.textContent = `⚖️ Peso bilancia: ${val} ${unit}${hintExtra}`; hint.style.display = ''; } - if (livLabel) livLabel.textContent = `✅ ${val} ${unit} — conferma automatica tra 5s (tocca per annullare)`; + if (livLabel) livLabel.textContent = t('scale.auto_confirm', { val, unit }); if (livVal) livVal.style.color = '#22c55e'; const confirmWrap2 = document.getElementById('ruse-scale-confirm-wrap'); if (confirmWrap2) { confirmWrap2.style.display = ''; } @@ -486,11 +486,11 @@ function _scaleAutoFillRecipeUse(msg) { }); } else if (!_scaleUserDismissed && !_scaleStabilityTimer && !_scaleAutoConfirmTimer) { _cancelScaleTimersOnly(); - if (livLabel) livLabel.textContent = 'Peso rilevato — attendi 10s di stabilità…'; + if (livLabel) livLabel.textContent = t('scale.weight_detected'); _startScaleStabilityWait(() => { const inp = document.getElementById('ruse-quantity'); if (inp) inp.value = val; - if (livLabel) livLabel.textContent = `✅ ${val} ${unit} — conferma automatica tra 5s (tocca per annullare)`; + if (livLabel) livLabel.textContent = t('scale.auto_confirm', { val, unit }); if (livVal) livVal.style.color = '#22c55e'; const confirmWrap3 = document.getElementById('ruse-scale-confirm-wrap'); if (confirmWrap3) confirmWrap3.style.display = ''; @@ -1769,7 +1769,7 @@ function _injectKioskOverlay() { exitBtn.style.cssText = btnStyle; exitBtn.addEventListener('click', (e) => { e.stopPropagation(); - if (confirm('Uscire dalla modalità kiosk?')) _kioskBridge.exit(); + if (confirm(t('confirm.kiosk_exit'))) _kioskBridge.exit(); }); // Refresh button @@ -2505,14 +2505,14 @@ function renderBannerItem() { iconEl.textContent = '⚠️'; let titleText, detailText; if (suspDq && !suspQty) { - titleText = `Confezione insolita: ${item.name}${item.brand ? ' (' + item.brand + ')' : ''}`; - detailText = `Hai impostato una confezione da ${item.default_quantity} ${item.package_unit} — la dimensione sembra molto alta. Controlla se è corretta o modifica.`; + titleText = `${t('dashboard.banner_review_unusual_pkg_title')}: ${item.name}${item.brand ? ' (' + item.brand + ')' : ''}`; + detailText = t('dashboard.banner_review_unusual_pkg_detail', { qty: item.default_quantity, unit: item.package_unit }); } else if (parseFloat(item.quantity) < t_.min) { - titleText = `Quantità molto bassa: ${item.name}${item.brand ? ' (' + item.brand + ')' : ''}`; - detailText = `Hai solo ${qtyDisplay} in inventario — sembra poco, potrebbe essere un errore di inserimento. Conferma se è corretto.`; + titleText = `${t('dashboard.banner_review_low_qty_title')}: ${item.name}${item.brand ? ' (' + item.brand + ')' : ''}`; + detailText = t('dashboard.banner_review_low_qty_detail', { qty: qtyDisplay }); } else { - titleText = `Quantità insolitamente alta: ${item.name}${item.brand ? ' (' + item.brand + ')' : ''}`; - detailText = `Hai ${qtyDisplay} in inventario — la cifra sembra molto alta. Conferma se è corretto o correggi.`; + titleText = `${t('dashboard.banner_review_high_qty_title')}: ${item.name}${item.brand ? ' (' + item.brand + ')' : ''}`; + detailText = t('dashboard.banner_review_high_qty_detail', { qty: qtyDisplay }); } titleEl.textContent = titleText; detailEl.textContent = detailText; @@ -2530,19 +2530,19 @@ function renderBannerItem() { const daysSince = parseInt(pred.days_since_restock) || 0; banner.className = 'alert-banner banner-prediction'; iconEl.textContent = '📊'; - titleEl.textContent = `Consumo anomalo: ${pred.name}${pred.brand ? ' (' + pred.brand + ')' : ''}`; + titleEl.textContent = `${t('dashboard.banner_prediction_title')}: ${pred.name}${pred.brand ? ' (' + pred.brand + ')' : ''}`; let rateText = ''; if (dailyRate > 0) { rateText = dailyRate >= 1 - ? `Media ~${Math.round(dailyRate)} ${pred.unit}/giorno` - : `Media ~${Math.round(dailyRate * 7)} ${pred.unit}/settimana`; + ? t('dashboard.banner_prediction_rate_day', { n: Math.round(dailyRate), unit: pred.unit }) + : t('dashboard.banner_prediction_rate_week', { n: Math.round(dailyRate * 7), unit: pred.unit }); } - const timeText = daysSince > 0 ? ` — ${daysSince} giorni fa hai rifornito` : ''; + const timeText = daysSince > 0 ? ` — ${t('dashboard.banner_prediction_days_ago', { n: daysSince })}` : ''; let diffText; if (dir === 'more') { - diffText = `mi aspettavo ${pred.expected_qty} ${pred.unit}${timeText}, ne hai invece ${pred.actual_qty} ${pred.unit}. Hai aggiunto scorte senza registrarle?`; + diffText = t('dashboard.banner_prediction_more', { expected: pred.expected_qty, unit: pred.unit, time: timeText, actual: pred.actual_qty }); } else { - diffText = `mi aspettavo ${pred.expected_qty} ${pred.unit}${timeText}, ne hai solo ${pred.actual_qty} ${pred.unit}. Hai consumato di più del solito?`; + diffText = t('dashboard.banner_prediction_less', { expected: pred.expected_qty, unit: pred.unit, time: timeText, actual: pred.actual_qty }); } detailEl.innerHTML = rateText ? `${rateText}: ${diffText}` : diffText.charAt(0).toUpperCase() + diffText.slice(1); let btns = ``; @@ -2560,8 +2560,8 @@ function renderBannerItem() { ? ` …${escapeHtml(fin.barcode.slice(-3))}` : ''; titleEl.innerHTML = `${escapeHtml(fin.name)}${fin.brand ? ' (' + escapeHtml(fin.brand) + ')' : ''}${barcodeSuffix} — ${escapeHtml(t('dashboard.banner_finished_title'))}`; - const expectedText = fin.expected_qty ? ` Secondo le registrazioni dovresti averne ancora ${fin.expected_qty} ${fin.unit}.` : ''; - detailEl.innerHTML = `L'inventario segna zero, ma i movimenti registrati dicono che non dovrebbe essere finito.${expectedText} Puoi controllare?`; + const expectedText = fin.expected_qty ? ' ' + t('dashboard.banner_finished_expected', { qty: fin.expected_qty, unit: fin.unit }) : ''; + detailEl.innerHTML = t('dashboard.banner_finished_zero') + expectedText + ' ' + t('dashboard.banner_finished_check'); let btns = ``; btns += ``; actionsEl.innerHTML = btns; @@ -2572,11 +2572,11 @@ function renderBannerItem() { banner.className = 'alert-banner banner-anomaly'; iconEl.textContent = '🔍'; if (isPhantom) { - titleEl.textContent = `${an.name} — hai più scorte del previsto`; - detailEl.innerHTML = `L'inventario segna ${an.inv_qty} ${an.unit}, ma in base alle entrate e uscite registrate ne dovresti avere solo ${an.expected_qty} ${an.unit}. Hai aggiunto scorte o corretto la quantità manualmente senza registrarlo?`; + titleEl.textContent = `${an.name} — ${t('dashboard.banner_anomaly_phantom_title')}`; + detailEl.innerHTML = t('dashboard.banner_anomaly_phantom_detail', { inv_qty: an.inv_qty, unit: an.unit, expected_qty: an.expected_qty }); } else { - titleEl.textContent = `${an.name} — hai meno scorte del previsto`; - detailEl.innerHTML = `In base alle operazioni registrate dovresti avere ${an.expected_qty} ${an.unit} di ${an.name}, ma l'inventario mostra solo ${an.inv_qty} ${an.unit}. Hai prelevato senza registrarlo?`; + titleEl.textContent = `${an.name} — ${t('dashboard.banner_anomaly_ghost_title')}`; + detailEl.innerHTML = t('dashboard.banner_anomaly_ghost_detail', { expected_qty: an.expected_qty, unit: an.unit, name: an.name, inv_qty: an.inv_qty }); } let btns = ``; btns += ``; @@ -4521,7 +4521,7 @@ function showProductAction() { statusBar.innerHTML = `