fix(i18n): localize PDF import error messages
Review surfaced 3 critical paths where hardcoded French leaked into
the EN UI:
- src/pdf/import.ts ImportError default message
- src/pdf/attachment.ts IncompatibleReportVersionError message
- src/app/routes/HomeRoute.tsx propagated err.message verbatim
Refactor:
- ImportError carries a typed `kind` discriminant
('invalid_pdf' | 'incompatible_version' | 'no_attachment') plus
optional `foundVersion`. Removes hardcoded localized strings.
- IncompatibleReportVersionError keeps `foundVersion` only; message
collapses to an internal sentinel.
- HomeRoute resolves the user-facing message via the active i18n
dict using `err.kind`, with `{version}` template substitution for
the incompatible-version case.
- 3 new dict keys (fr+en): home.import.error_invalid_pdf,
home.import.error_no_attachment, home.import.error_incompatible_version
- pdf.roundtrip v1 case asserts ImportError instance + kind +
foundVersion instead of grepping the message text.
154/154 tests pass, lint clean, typecheck clean, build OK.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
fa3eb51394
commit
9916c42484
6 files changed
+61
-16
No files matched your search
@@ -27,6 +27,12 @@ export const fr: Dict = {
|
||||
'home.import.cta': 'Choisir un PDF',
|
||||
'home.import.loading': 'Lecture…',
|
||||
'home.import.error_generic': 'Erreur de lecture du PDF.',
|
||||
'home.import.error_invalid_pdf':
|
||||
"Ce fichier n'est pas un PDF lisible.",
|
||||
'home.import.error_no_attachment':
|
||||
"Ce PDF n'a pas été généré par Osteo Report (pas de données détectées).",
|
||||
'home.import.error_incompatible_version':
|
||||
"Ce PDF est au format v{version}, incompatible avec la version actuelle (v2). Réexportez le bilan depuis une version récente de l'application.",
|
||||
|
||||
// not found
|
||||
'not_found.title': 'Page introuvable',
|
||||
|
||||
Reference in new issue
Block a user