fix(medications): localise time-window range string

`formatTimeWindowRange` used to hard-code the German "bis ... Uhr"
suffix, so an English-locale user saw "Today, 19:00 bis 23:00 Uhr"
on the medication card and the medication form. Pass the active
locale through and emit "19:00 – 23:00" for English while keeping
the existing German output for DE users (and unchanged for legacy
call sites that still don't pass a locale).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marc-André BombeckandClaude Opus 4.7 committed 2026-05-10 13:29:07 +02:00
1 parent 79ad5c47a9
commit 180f46c24e
4 files changed
+74 -8

No files matched your search

@@ -193,7 +193,7 @@ function isLastIntakeInCurrentWindow(
export function MedicationCard({ medication, onEdit }: MedicationCardProps) {
const queryClient = useQueryClient();
const { t } = useTranslations();
const { t, locale } = useTranslations();
const fmt = useFormatters();
const [intakeLoading, setIntakeLoading] = useState<string | null>(null);
@@ -438,6 +438,7 @@ export function MedicationCard({ medication, onEdit }: MedicationCardProps) {
{formatTimeWindowRange(
currentWindowStatus.schedule!.windowStart,
currentWindowStatus.schedule!.windowEnd,
locale,
)}
</span>
</p>
@@ -490,7 +491,7 @@ export function MedicationCard({ medication, onEdit }: MedicationCardProps) {
{t("medications.nextIntake")}
</span>{" "}
{dayLabel && `${dayLabel}, `}
{formatTimeWindowRange(s.windowStart, s.windowEnd)}
{formatTimeWindowRange(s.windowStart, s.windowEnd, locale)}
{s.label && (
<span className="hidden sm:inline"> ({s.label})</span>
)}
@@ -131,16 +131,17 @@ function formatNextWindowSummary(
schedule: Schedule,
t: TranslateFn,
formatShortDate: (date: Date) => string,
locale: "de" | "en",
): string {
const isSimpleDaily =
schedule.daysOfWeek.length === 0 && schedule.intervalWeeks === 1;
if (isSimpleDaily) {
return `${t("medications.nextSchedulePrefix")} ${t("medications.nextScheduleDaily")}, ${formatTimeWindowRange(schedule.windowStart, schedule.windowEnd)}`;
return `${t("medications.nextSchedulePrefix")} ${t("medications.nextScheduleDaily")}, ${formatTimeWindowRange(schedule.windowStart, schedule.windowEnd, locale)}`;
}
const nextDate = getNextRecurrenceDate(schedule);
const nextText = nextDate
? `${formatShortDate(nextDate)}, ${formatTimeWindowRange(schedule.windowStart, schedule.windowEnd)}`
? `${formatShortDate(nextDate)}, ${formatTimeWindowRange(schedule.windowStart, schedule.windowEnd, locale)}`
: "—";
return `${t("medications.nextSchedulePrefix")} ${nextText}`;
}
@@ -234,7 +235,7 @@ export function MedicationForm({
initial,
}: MedicationFormProps) {
const queryClient = useQueryClient();
const { t } = useTranslations();
const { t, locale } = useTranslations();
const fmt = useFormatters();
const doseUnits = [
@@ -565,7 +566,7 @@ export function MedicationForm({
`${t("medications.formSchedule")} ${i + 1}`}
</span>{" "}
<span className="text-foreground/70 font-normal">
({formatNextWindowSummary(s, t, fmt.dateShort)})
({formatNextWindowSummary(s, t, fmt.dateShort, locale)})
</span>
</p>
<DropdownMenu>