mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
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.
30 lines
792 B
TypeScript
30 lines
792 B
TypeScript
/**
|
|
* Canonical dose-unit key list — the single source of truth shared by the
|
|
* wizard's dose step (the unit `<Select>`) and the display-time
|
|
* {@link formatDose} helper. Keep both in lock-step by importing from here;
|
|
* never re-declare the array.
|
|
*
|
|
* Ordered so mg / ml / IE / µg lead and the device-form units
|
|
* (Tablette, Hub, Sprühstoß, …) follow. Mirrors the v1.5.3 list with the
|
|
* maintainer-requested order tightening.
|
|
*
|
|
* Each key resolves to a localised label at
|
|
* `medications.wizard.steps.step3.unit.<key>` in every locale bundle.
|
|
*/
|
|
export const DOSE_UNIT_KEYS = [
|
|
"mg",
|
|
"ml",
|
|
"iu",
|
|
"mcg",
|
|
"g",
|
|
"tablets",
|
|
"capsules",
|
|
"drops",
|
|
"puffs",
|
|
"sprays",
|
|
"pieces",
|
|
"other",
|
|
] as const;
|
|
|
|
export type DoseUnitKey = (typeof DOSE_UNIT_KEYS)[number];
|