Write the Coach read strip's second line in the reader's language

On a German metric page the strip printed its own summary in German and
the pattern line under it in English. The pattern line is a finished
sentence the server writes, and the route never told the server who was
reading, so it wrote English.

The route now resolves the reader's language the same way the
correlations and analytics routes do and passes it down. The language is
a required argument the whole way through — it used to be optional with
an English fallback, which is why a caller could stay silent and still
get a sentence back. The cycle page's lagged rows had the same gap and
are fixed with it.

The strip's browser cache is keyed by language too, so switching
language no longer re-uses the sentence written for the previous one.
This commit is contained in:
Marc-André Bombeck committed 2026-07-31 08:52:23 +02:00
1 parent 340d1db6d9
commit 4ed6f7d1ce
30 files changed
+394 -161

No files matched your search

@@ -77,7 +77,7 @@ export function CoachReadStrip({
const resolvedUnit = transformed ? unitDisplay.unitFor(metricType) : unit;
const { data } = useQuery({
queryKey: queryKeys.insightsCoachRead(metricType),
queryKey: queryKeys.insightsCoachRead(metricType, locale),
queryFn: () =>
apiGet<CoachReadStripData>(
`/api/insights/coach-read?metric=${encodeURIComponent(metricType)}`,
@@ -120,6 +120,10 @@ export function CoachReadStrip({
});
})();
// Only the wrapper is translated here. `note` is a finished sentence the
// server wrote in the reader's language, so it goes in as it arrived — which
// is exactly why the route has to know the language, and why this query is
// keyed by locale.
const driverLine = data.driver
? t("insights.coach.readStrip.driver", { note: data.driver.note })
: null;