fix(medications): localise the dose unit and lift it onto its own line

A medication's dose is stored as free text the wizard composes from an
amount and a unit token ("1 pieces", "2 tablets"), and the card rendered
that token verbatim glued onto the name — so the unit showed in English
on every locale and the title read "Test ABC 1 pieces".

Translate the dose at display time: a formatDose helper splits the stored
string and runs a known unit token through the existing unit messages, so
"1 pieces" reads "1 Stück" / "1 piece(s)" per locale while a custom
free-text dose passes through untouched. The card header now carries the
name alone on its title line with the dose on a muted line beneath it,
above the category badge; the detail view, table and intake dialogs
localise the same way. Vorsorge and lab rows pass an empty dose so they
render no extra line.
This commit is contained in:
Marc-André Bombeck committed 2026-06-30 13:39:23 +02:00
1 parent a31711699c
commit 6fe552ffdf
14 files changed
+180 -43

No files matched your search

@@ -80,6 +80,7 @@ import { queryKeys } from "@/lib/query-keys";
import { formatUnitCount } from "@/components/medications/units-per-dose";
import { apiGet } from "@/lib/api/api-fetch";
import { useTranslations, useFormatters } from "@/lib/i18n/context";
import { formatDose } from "@/lib/medications/format-dose";
import type { MedicationPayload } from "@/components/medications/wizard/wizard-payload";
import type { ComplianceDisplay } from "@/lib/analytics/compliance";
@@ -392,7 +393,7 @@ export function MedicationDetailTabs({
page" and misled). `?edit=1` still opens the wizard directly. */}
<MedicationDetailSummary
name={medication.name}
dose={medication.dose}
dose={formatDose(medication.dose, t)}
active={medication.active}
endsOn={medication.endsOn}
payload={payload}