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
@@ -3,6 +3,7 @@ import Label from '@/components/ui/Label'
|
||||
import Input from '@/components/ui/Input'
|
||||
import Select from '@/components/ui/Select'
|
||||
import { getAllSpecies } from '@/domain/species/registry'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
export interface AnimalFormProps {
|
||||
animal: Animal
|
||||
@@ -12,13 +13,16 @@ export interface AnimalFormProps {
|
||||
}
|
||||
|
||||
export default function AnimalForm({ animal, owner, onChangeAnimal, onChangeOwner }: AnimalFormProps) {
|
||||
const t = useT()
|
||||
const species = getAllSpecies()
|
||||
const setA = (patch: Partial<Animal>) => onChangeAnimal({ ...animal, ...patch })
|
||||
return (
|
||||
<fieldset className="space-y-3">
|
||||
<legend className="font-serif text-xl mb-2 text-[var(--color-ink)]">Animal & propriétaire</legend>
|
||||
<legend className="font-serif text-xl mb-2 text-[var(--color-ink)]">
|
||||
{t('form.animal.legend')}
|
||||
</legend>
|
||||
<div>
|
||||
<Label htmlFor="an-species">Espèce *</Label>
|
||||
<Label htmlFor="an-species">{t('form.animal.species')}</Label>
|
||||
<Select
|
||||
id="an-species"
|
||||
value={animal.speciesId}
|
||||
@@ -30,19 +34,19 @@ export default function AnimalForm({ animal, owner, onChangeAnimal, onChangeOwne
|
||||
</Select>
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="an-name">Nom de l'animal *</Label>
|
||||
<Label htmlFor="an-name">{t('form.animal.name')}</Label>
|
||||
<Input id="an-name" required value={animal.name} onChange={(e) => setA({ name: e.target.value })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="an-breed">Race</Label>
|
||||
<Label htmlFor="an-breed">{t('form.animal.breed')}</Label>
|
||||
<Input id="an-breed" value={animal.breed ?? ''} onChange={(e) => setA({ breed: e.target.value || undefined })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="an-age">Âge</Label>
|
||||
<Label htmlFor="an-age">{t('form.animal.age')}</Label>
|
||||
<Input id="an-age" value={animal.age ?? ''} onChange={(e) => setA({ age: e.target.value || undefined })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="own-name">Nom du propriétaire *</Label>
|
||||
<Label htmlFor="own-name">{t('form.owner.name')}</Label>
|
||||
<Input id="own-name" required value={owner.name} onChange={(e) => onChangeOwner({ name: e.target.value })} />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { Report } from '@/domain/schema/report'
|
||||
import Label from '@/components/ui/Label'
|
||||
import Textarea from '@/components/ui/Textarea'
|
||||
import NextAppointmentPicker from './NextAppointmentPicker'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
export interface ConclusionPanelProps {
|
||||
conclusion: string
|
||||
@@ -20,15 +21,18 @@ export default function ConclusionPanel({
|
||||
onChangeRecommendations,
|
||||
onChangeNextAppointment,
|
||||
}: ConclusionPanelProps) {
|
||||
const t = useT()
|
||||
return (
|
||||
<section className="space-y-4">
|
||||
<h2 className="font-serif text-xl text-[var(--color-ink)]">Conclusion & recommandations</h2>
|
||||
<h2 className="font-serif text-xl text-[var(--color-ink)]">
|
||||
{t('conclusion.section_title')}
|
||||
</h2>
|
||||
<div>
|
||||
<Label htmlFor="conclusion">Conclusion</Label>
|
||||
<Label htmlFor="conclusion">{t('conclusion.conclusion')}</Label>
|
||||
<Textarea id="conclusion" value={conclusion} onChange={(e) => onChangeConclusion(e.target.value)} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="recommendations">Recommandations</Label>
|
||||
<Label htmlFor="recommendations">{t('conclusion.recommendations')}</Label>
|
||||
<Textarea id="recommendations" value={recommendations} onChange={(e) => onChangeRecommendations(e.target.value)} />
|
||||
</div>
|
||||
<NextAppointmentPicker value={nextAppointment} onChange={onChangeNextAppointment} />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Report } from '@/domain/schema/report'
|
||||
import Input from '@/components/ui/Input'
|
||||
import Label from '@/components/ui/Label'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
export interface NextAppointmentPickerProps {
|
||||
value: Report['nextAppointment']
|
||||
@@ -11,10 +12,11 @@ export default function NextAppointmentPicker({
|
||||
value,
|
||||
onChange,
|
||||
}: NextAppointmentPickerProps) {
|
||||
const t = useT()
|
||||
const kind = value?.kind
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<Label>Prochain rendez-vous</Label>
|
||||
<Label>{t('conclusion.next_appointment')}</Label>
|
||||
<div className="flex gap-2 mb-2">
|
||||
<label className="text-sm flex items-center gap-1">
|
||||
<input
|
||||
@@ -22,7 +24,7 @@ export default function NextAppointmentPicker({
|
||||
checked={kind === 'date'}
|
||||
onChange={() => onChange({ kind: 'date', date: '' })}
|
||||
/>
|
||||
Date
|
||||
{t('conclusion.next_kind_date')}
|
||||
</label>
|
||||
<label className="text-sm flex items-center gap-1">
|
||||
<input
|
||||
@@ -30,7 +32,7 @@ export default function NextAppointmentPicker({
|
||||
checked={kind === 'period'}
|
||||
onChange={() => onChange({ kind: 'period', text: '' })}
|
||||
/>
|
||||
Période libre
|
||||
{t('conclusion.next_kind_period')}
|
||||
</label>
|
||||
<label className="text-sm flex items-center gap-1">
|
||||
<input
|
||||
@@ -38,7 +40,7 @@ export default function NextAppointmentPicker({
|
||||
checked={value === undefined}
|
||||
onChange={() => onChange(undefined)}
|
||||
/>
|
||||
Aucun
|
||||
{t('conclusion.next_kind_none')}
|
||||
</label>
|
||||
</div>
|
||||
{value?.kind === 'date' && (
|
||||
@@ -51,7 +53,7 @@ export default function NextAppointmentPicker({
|
||||
{value?.kind === 'period' && (
|
||||
<Input
|
||||
value={value.text}
|
||||
placeholder="ex. dans 3 semaines"
|
||||
placeholder={t('conclusion.next_period_placeholder')}
|
||||
onChange={(e) => onChange({ kind: 'period', text: e.target.value })}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Practitioner } from '@/domain/schema/practitioner'
|
||||
import Label from '@/components/ui/Label'
|
||||
import Input from '@/components/ui/Input'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
export interface PractitionerFormProps {
|
||||
value: Practitioner
|
||||
@@ -8,24 +9,27 @@ export interface PractitionerFormProps {
|
||||
}
|
||||
|
||||
export default function PractitionerForm({ value, onChange }: PractitionerFormProps) {
|
||||
const t = useT()
|
||||
const set = (patch: Partial<Practitioner>) => onChange({ ...value, ...patch })
|
||||
return (
|
||||
<fieldset className="space-y-3">
|
||||
<legend className="font-serif text-xl mb-2 text-[var(--color-ink)]">Praticien</legend>
|
||||
<legend className="font-serif text-xl mb-2 text-[var(--color-ink)]">
|
||||
{t('form.practitioner.legend')}
|
||||
</legend>
|
||||
<div>
|
||||
<Label htmlFor="prac-name">Nom complet *</Label>
|
||||
<Label htmlFor="prac-name">{t('form.practitioner.name')}</Label>
|
||||
<Input id="prac-name" required value={value.name} onChange={(e) => set({ name: e.target.value })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="prac-cabinet">Cabinet / clinique</Label>
|
||||
<Label htmlFor="prac-cabinet">{t('form.practitioner.cabinet')}</Label>
|
||||
<Input id="prac-cabinet" value={value.cabinet ?? ''} onChange={(e) => set({ cabinet: e.target.value || undefined })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="prac-contact">Contact (téléphone, email…)</Label>
|
||||
<Label htmlFor="prac-contact">{t('form.practitioner.contact')}</Label>
|
||||
<Input id="prac-contact" value={value.contact ?? ''} onChange={(e) => set({ contact: e.target.value || undefined })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="prac-siret">SIRET</Label>
|
||||
<Label htmlFor="prac-siret">{t('form.practitioner.siret')}</Label>
|
||||
<Input id="prac-siret" value={value.siret ?? ''} onChange={(e) => set({ siret: e.target.value || undefined })} />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
import type { Report } from '@/domain/schema/report'
|
||||
import Brand from '@/components/brand/Brand'
|
||||
import LanguageSwitcher from '@/components/brand/LanguageSwitcher'
|
||||
import Button from '@/components/ui/Button'
|
||||
import { formatDateFr } from '@/lib/dates'
|
||||
import { formatDate } from '@/lib/dates'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
|
||||
export interface ReportHeaderProps {
|
||||
report: Report
|
||||
@@ -11,6 +14,8 @@ export interface ReportHeaderProps {
|
||||
|
||||
export default function ReportHeader({ report, onEditInfos }: ReportHeaderProps) {
|
||||
const navigate = useNavigate()
|
||||
const t = useT()
|
||||
const locale = useLocaleStore((s) => s.locale)
|
||||
return (
|
||||
<header className="flex items-center justify-between gap-4 px-6 py-3 border-b border-[var(--color-border)] bg-[var(--color-surface)]">
|
||||
<div className="flex items-center gap-3">
|
||||
@@ -18,28 +23,29 @@ export default function ReportHeader({ report, onEditInfos }: ReportHeaderProps)
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => navigate('/')}
|
||||
aria-label="Retour à l'accueil"
|
||||
aria-label={t('common.back_to_home')}
|
||||
>
|
||||
← Accueil
|
||||
← {t('common.home')}
|
||||
</Button>
|
||||
<Link
|
||||
to="/"
|
||||
aria-label="Retour à l'accueil"
|
||||
aria-label={t('common.back_to_home')}
|
||||
className="rounded-md px-1 py-0.5 hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]"
|
||||
>
|
||||
<Brand />
|
||||
</Link>
|
||||
</div>
|
||||
<div className="flex items-center gap-4">
|
||||
<LanguageSwitcher />
|
||||
<div className="text-sm text-right text-[var(--color-ink-muted)]">
|
||||
<div className="text-[var(--color-ink)] font-medium">
|
||||
{report.animal.name} · {report.owner.name}
|
||||
</div>
|
||||
<div>{formatDateFr(report.date)}</div>
|
||||
<div>{formatDate(report.date, locale)}</div>
|
||||
</div>
|
||||
{onEditInfos && (
|
||||
<Button variant="secondary" size="sm" onClick={onEditInfos}>
|
||||
Modifier les infos
|
||||
{t('editor.edit_infos')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user