feat(i18n): navigator-detect default locale + locale-aware bone labels

- localeStore.readInitial now consults navigator.language(s) when
  localStorage is empty (first fr/en hit, FR fallback). Persisted user
  choice still wins.
- New helper src/anatomy/labels.ts (boneLabel(b, locale, fallback))
  with cross-language fallback so missing labels never render blank.
- AnatomyCanvas rewrites native SVG <title> tooltips per locale on
  mount and on locale change (upstream SVG ships titles as "FR / EN"
  concat; we replace with the active-locale label only). Detail-popup
  trigger titles ("🔍 Zoom: …") left intact.
- DetailModal + EditorRoute detail title prefix + vertebra picker
  title now route through useT()/boneLabel.
- ObservationCard.describeZone takes locale, picks bone.fr / bone.en.
- PDF: buildZoneLabels returns Map<id, { fr, en }> instead of FR-only;
  observationPage picks per locale with cross-language fallback.
- Tests: FindingsTreePicker + VertebraPicker reset locale to 'fr' in
  beforeEach (navigator-detect may land on EN in happy-dom).
- pdf.zoneLabels test updated to assert the new pair shape.

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:
Bastien ChanotandClaude Opus 4.7 committed 2026-05-20 07:56:22 +02:00
1 parent 31bd82de58
commit 9cf8a66dad
13 files changed
+156 -35

No files matched your search

+8 -3
View File
@@ -25,6 +25,7 @@ import type { Animal, Owner } from '@/domain/schema/animal'
import { exportReportToPdf } from '@/pdf/export'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
import { boneLabel } from '@/anatomy/labels'
const DISCLAIMER_FLAG = 'osteo:disclaimer-shown'
@@ -198,7 +199,7 @@ export default function EditorRoute() {
setDetail({
id: bone.opensDetail,
src: species.details[bone.opensDetail],
title: bone.fr,
title: boneLabel(bone, locale, bone.opensDetail),
})
return
}
@@ -323,7 +324,7 @@ export default function EditorRoute() {
onClose={() => setDetail(null)}
detailSrc={detail.src}
detailId={detail.id}
title={`Détail — ${detail.title}`}
title={`${t('editor.detail_title_prefix')}${detail.title}`}
boneStates={boneStates}
onZoneClick={(id, did) => onZoneClick(id, did)}
/>
@@ -408,7 +409,11 @@ export default function EditorRoute() {
}}
initial={activeObs.zones[vertebraTarget].vertebrae ?? []}
formula={species.vertebralFormula}
title={`${t('vertebra.title_prefix')}${bones.get(activeObs.zones[vertebraTarget].boneId)?.fr ?? ''}`}
title={`${t('vertebra.title_prefix')}${boneLabel(
bones.get(activeObs.zones[vertebraTarget].boneId),
locale,
'',
)}`}
initialRegion={(() => {
const b = bones.get(activeObs.zones[vertebraTarget].boneId)
return regionFromLabel(b?.fr ?? '') ?? regionFromLabel(b?.en ?? '')