feat(i18n): migrate site + PDF to locale-aware rendering
- formatDate(iso, locale) replaces formatDateFr in src/lib/dates.ts
- exportReportToPdf(report, { locale }) takes explicit locale option
- LanguageSwitcher segmented FR | EN toggle added; integrated in
ReportHeader, HomeRoute, NewReportRoute
- All routes (Home, NewReport, Editor, NotFound) + observation
components (FindingsTreePicker, ObservationCard, FreeTextFindingInput,
SeveritySelector, VertebraPicker, ObservationList) + report forms
(PractitionerForm, AnimalForm, ConclusionPanel, NextAppointmentPicker)
route hardcoded FR via useT()
- PDF render functions (export.ts, header.ts, footer.ts,
observationPage.ts, conclusionPage.ts) take a locale arg and read
static labels from the dict snapshot at call time
- Catalog finding leaf labels rendered via labelFr/EnSnapshot per locale
- description_fr / scope_disclaimer stay FR-only (out of scope —
vet-expert authoring needed for EN copy)
- LanguageSwitcher unit test (2) + lib.dates locale tests (7) cover
the new behavior
151/151 tests pass, lint 0, typecheck clean, vite build OK
(902KB main + 15KB lazy pathologies chunk).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
359104ce88
commit
d6027266bc
25 files changed
+390
-207
No files matched your search
@@ -1,7 +1,9 @@
|
||||
import { rgb, type PDFPage } from 'pdf-lib'
|
||||
import type { EmbeddedFonts } from '@/pdf/fonts'
|
||||
import type { Locale } from '@/i18n/types'
|
||||
import { appConfig } from '@/config/env'
|
||||
import { formatDateFr, todayIso } from '@/lib/dates'
|
||||
import { formatDate, todayIso } from '@/lib/dates'
|
||||
import { getDict } from '@/i18n'
|
||||
|
||||
const MARGIN_X = 36
|
||||
const FOOTER_Y = 28
|
||||
@@ -11,11 +13,13 @@ export function drawFooter(
|
||||
fonts: EmbeddedFonts,
|
||||
pageNumber: number,
|
||||
totalPages: number,
|
||||
locale: Locale,
|
||||
): void {
|
||||
const dict = getDict(locale)
|
||||
const { width } = page.getSize()
|
||||
const muted = rgb(0.42, 0.39, 0.35)
|
||||
const left = appConfig.footerName
|
||||
const center = `Exporté le ${formatDateFr(todayIso())}`
|
||||
const center = `${dict['pdf.export_date_prefix']}${formatDate(todayIso(), locale)}`
|
||||
const right = `${pageNumber} / ${totalPages}`
|
||||
|
||||
page.drawText(left, { x: MARGIN_X, y: FOOTER_Y, size: 9, font: fonts.bodyRegular, color: muted })
|
||||
|
||||
Reference in new issue
Block a user