From a40bf549e558c2bb8b320f1ae045a1dd8f7dfb56 Mon Sep 17 00:00:00 2001 From: u8array Date: Tue, 28 Jul 2026 18:40:21 +0200 Subject: [PATCH] feat(i18n): localize ZPL import modal and findings report --- src/components/Output/ImportSummary.tsx | 12 ++-- src/components/Output/ZplImportModal.tsx | 31 ++++----- src/lib/importReport.ts | 80 +++++++++++------------- src/lib/zplCommandSupport.ts | 23 ++++--- src/lib/zplImportService.test.ts | 5 +- src/locales/ar.ts | 35 +++++++++++ src/locales/bg.ts | 35 +++++++++++ src/locales/cs.ts | 35 +++++++++++ src/locales/da.ts | 35 +++++++++++ src/locales/de.ts | 35 +++++++++++ src/locales/el.ts | 35 +++++++++++ src/locales/en.ts | 35 +++++++++++ src/locales/es.ts | 35 +++++++++++ src/locales/et.ts | 35 +++++++++++ src/locales/fa.ts | 35 +++++++++++ src/locales/fi.ts | 35 +++++++++++ src/locales/fr.ts | 35 +++++++++++ src/locales/he.ts | 35 +++++++++++ src/locales/hr.ts | 35 +++++++++++ src/locales/hu.ts | 35 +++++++++++ src/locales/it.ts | 35 +++++++++++ src/locales/ja.ts | 35 +++++++++++ src/locales/ko.ts | 35 +++++++++++ src/locales/lt.ts | 35 +++++++++++ src/locales/lv.ts | 35 +++++++++++ src/locales/nl.ts | 35 +++++++++++ src/locales/no.ts | 35 +++++++++++ src/locales/pl.ts | 35 +++++++++++ src/locales/pt.ts | 35 +++++++++++ src/locales/ro.ts | 35 +++++++++++ src/locales/sk.ts | 35 +++++++++++ src/locales/sl.ts | 35 +++++++++++ src/locales/sr.ts | 35 +++++++++++ src/locales/sv.ts | 35 +++++++++++ src/locales/tr.ts | 35 +++++++++++ src/locales/zh-hans.ts | 35 +++++++++++ src/locales/zh-hant.ts | 35 +++++++++++ 37 files changed, 1201 insertions(+), 70 deletions(-) diff --git a/src/components/Output/ImportSummary.tsx b/src/components/Output/ImportSummary.tsx index 7a98a89f..fa6caac5 100644 --- a/src/components/Output/ImportSummary.tsx +++ b/src/components/Output/ImportSummary.tsx @@ -1,6 +1,7 @@ import { describeFinding } from '../../lib/importReport'; import type { ImportResult } from '../../lib/importReport'; import type { ImportFinding, ImportFindingKind } from '@zplab/core/lib/importReport'; +import { useT } from '../../hooks/useT'; export type { ImportResult }; @@ -26,12 +27,13 @@ const TONE: Record = { }; export function FindingRow({ finding, showPage }: { finding: ImportFinding; showPage: boolean }) { - const { title, detail } = describeFinding(finding); + const t = useT(); + const { title, detail } = describeFinding(finding, t.importReport); return (
{showPage && ( - Page {finding.pageIndex + 1} + {t.importReport.pageFmt.replace('{n}', String(finding.pageIndex + 1))} )}
@@ -47,6 +49,7 @@ export function FindingRow({ finding, showPage }: { finding: ImportFinding; show } export function ImportSummaryBody({ result }: { result: ImportResult }) { + const t = useT(); const { objectCount, report } = result; const { findings } = report; // Only show per-row page badges when the import actually spanned multiple @@ -56,8 +59,9 @@ export function ImportSummaryBody({ result }: { result: ImportResult }) { return (

- Imported {objectCount} object{objectCount !== 1 ? 's' : ''} with{' '} - {findings.length} issue{findings.length !== 1 ? 's' : ''}: + {t.importModal.summaryFmt + .replace('{n}', String(objectCount)) + .replace('{m}', String(findings.length))}

{findings.map((f, i) => ( diff --git a/src/components/Output/ZplImportModal.tsx b/src/components/Output/ZplImportModal.tsx index d09ca27b..7225fe55 100644 --- a/src/components/Output/ZplImportModal.tsx +++ b/src/components/Output/ZplImportModal.tsx @@ -112,7 +112,7 @@ export function ZplImportModal({ onClose }: Props) { Object.keys(labelConfig).length === 0 && Object.keys(printerProfile).length === 0 ) { - setError('No supported objects found in the ZPL code.'); + setError(t.importModal.errNoObjects); return; } if (replayRiskFindings(imported.report).length > 0) { @@ -125,7 +125,7 @@ export function ZplImportModal({ onClose }: Props) { const handleImport = () => { setError(null); if (!zpl.trim()) { - setError('Please paste some ZPL code first.'); + setError(t.importModal.errPasteFirst); return; } processImport(zpl); @@ -141,12 +141,12 @@ export function ZplImportModal({ onClose }: Props) { try { text = await readFileAsText(file); } catch { - setError('Could not read the file.'); + setError(t.importModal.errFileRead); return; } if (!text.trim()) { - setError('The file appears to be empty.'); + setError(t.importModal.errFileEmpty); return; } processImport(text); @@ -154,7 +154,7 @@ export function ZplImportModal({ onClose }: Props) { const handleCopy = () => { if (!result) return; - void copyText(formatReportAsText(result)).then((r) => { + void copyText(formatReportAsText(result, t.importReport)).then((r) => { if (r !== 'copied') return; setCopied(true); setTimeout(() => setCopied(false), 1500); @@ -197,8 +197,8 @@ export function ZplImportModal({ onClose }: Props) { className="flex items-center gap-1.5 font-mono text-[10px] text-muted hover:text-text transition-colors" > {copied - ? <> Copied - : <> Copy report} + ? <> {t.importModal.copied} + : <> {t.importModal.copyReport}}