fix(report): pass the in-app locale through to the pdf export

The health-record export panel sent no locale, so the server resolved the
report language from the browser's Accept-Language header. A German user on
an English-default browser got an English doctor report.

Send the active in-app locale from the panel, and on the server resolve
most-specific-first: explicit selection, then the healthlog-locale cookie
(what the user actually chose in the UI), then Accept-Language as the
weakest fallback.
This commit is contained in:
Marc-André Bombeck committed 2026-05-31 22:47:44 +02:00
1 parent 24ffca7220
commit c6e782cdb8
3 files changed
+74 -4

No files matched your search

@@ -97,7 +97,7 @@ function buildSelectionSections(s: SectionState) {
}
export function HealthRecordExportPanel() {
const { t } = useTranslations();
const { t, locale } = useTranslations();
const [format, setFormat] = useState<ExportFormat>("pdf");
const [days, setDays] = useState<number>(90);
const [practiceName, setPracticeName] = useState("");
@@ -140,6 +140,10 @@ export function HealthRecordExportPanel() {
credentials: "include",
body: JSON.stringify({
format,
// Carry the active in-app locale so the generated artefact matches
// the UI language instead of falling back to the browser's
// Accept-Language header on the server.
locale,
range: { days },
practiceName: practiceName.trim() || undefined,
includeCharts,