mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
fix(i18n): sleep headline suffix translates across all six locales
The 'per night' caption beneath the sleep headline was branching on `locale === "de"` and falling through to English for FR/IT/ES/PL. Move the string into `insights.sleep.headlineCaptionSuffix` with native translations (de: pro Nacht, fr: par nuit, it: per notte, es: por noche, pl: na noc) and resolve it through `t()`.
This commit is contained in:
1 parent
c38a2c8a2a
commit
e14466e238
7 files changed
+12
-11
No files matched your search
@@ -1081,6 +1081,7 @@
|
|||||||
"description": "Phasen-Aufschlüsselung und nächtliche Dauer – gezogen aus Apple Health.",
|
"description": "Phasen-Aufschlüsselung und nächtliche Dauer – gezogen aus Apple Health.",
|
||||||
"headlineTitle": "Durchschnitt pro Nacht",
|
"headlineTitle": "Durchschnitt pro Nacht",
|
||||||
"headlineCaption": "Gemittelt über {count} Nächte – {suffix}",
|
"headlineCaption": "Gemittelt über {count} Nächte – {suffix}",
|
||||||
|
"headlineCaptionSuffix": "pro Nacht",
|
||||||
"compositionTitle": "Phasen-Verteilung",
|
"compositionTitle": "Phasen-Verteilung",
|
||||||
"compositionSubtitle": "Letzte {nights} Nächte",
|
"compositionSubtitle": "Letzte {nights} Nächte",
|
||||||
"compositionAriaLabel": "Schlafphasen-Verteilung über {nights} Nächte",
|
"compositionAriaLabel": "Schlafphasen-Verteilung über {nights} Nächte",
|
||||||
|
|||||||
@@ -1081,6 +1081,7 @@
|
|||||||
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
||||||
"headlineTitle": "Average per night",
|
"headlineTitle": "Average per night",
|
||||||
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
||||||
|
"headlineCaptionSuffix": "per night",
|
||||||
"compositionTitle": "Stage composition",
|
"compositionTitle": "Stage composition",
|
||||||
"compositionSubtitle": "Last {nights} nights",
|
"compositionSubtitle": "Last {nights} nights",
|
||||||
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
||||||
|
|||||||
@@ -1081,6 +1081,7 @@
|
|||||||
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
||||||
"headlineTitle": "Average per night",
|
"headlineTitle": "Average per night",
|
||||||
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
||||||
|
"headlineCaptionSuffix": "por noche",
|
||||||
"compositionTitle": "Stage composition",
|
"compositionTitle": "Stage composition",
|
||||||
"compositionSubtitle": "Last {nights} nights",
|
"compositionSubtitle": "Last {nights} nights",
|
||||||
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
||||||
|
|||||||
@@ -1081,6 +1081,7 @@
|
|||||||
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
||||||
"headlineTitle": "Average per night",
|
"headlineTitle": "Average per night",
|
||||||
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
||||||
|
"headlineCaptionSuffix": "par nuit",
|
||||||
"compositionTitle": "Stage composition",
|
"compositionTitle": "Stage composition",
|
||||||
"compositionSubtitle": "Last {nights} nights",
|
"compositionSubtitle": "Last {nights} nights",
|
||||||
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
||||||
|
|||||||
@@ -1081,6 +1081,7 @@
|
|||||||
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
||||||
"headlineTitle": "Average per night",
|
"headlineTitle": "Average per night",
|
||||||
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
||||||
|
"headlineCaptionSuffix": "per notte",
|
||||||
"compositionTitle": "Stage composition",
|
"compositionTitle": "Stage composition",
|
||||||
"compositionSubtitle": "Last {nights} nights",
|
"compositionSubtitle": "Last {nights} nights",
|
||||||
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
||||||
|
|||||||
@@ -1081,6 +1081,7 @@
|
|||||||
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
||||||
"headlineTitle": "Average per night",
|
"headlineTitle": "Average per night",
|
||||||
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
||||||
|
"headlineCaptionSuffix": "na noc",
|
||||||
"compositionTitle": "Stage composition",
|
"compositionTitle": "Stage composition",
|
||||||
"compositionSubtitle": "Last {nights} nights",
|
"compositionSubtitle": "Last {nights} nights",
|
||||||
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
||||||
|
|||||||
@@ -53,19 +53,13 @@ interface SleepAnalyticsResponse {
|
|||||||
function formatHoursMinutes(
|
function formatHoursMinutes(
|
||||||
totalMinutes: number,
|
totalMinutes: number,
|
||||||
locale: string,
|
locale: string,
|
||||||
): { primary: string; suffix: string } {
|
): { primary: string } {
|
||||||
const hours = Math.floor(totalMinutes / 60);
|
const hours = Math.floor(totalMinutes / 60);
|
||||||
const mins = Math.round(totalMinutes - hours * 60);
|
const mins = Math.round(totalMinutes - hours * 60);
|
||||||
if (locale === "de") {
|
if (locale === "de") {
|
||||||
return {
|
return { primary: `${hours} Std. ${mins} Min.` };
|
||||||
primary: `${hours} Std. ${mins} Min.`,
|
|
||||||
suffix: "pro Nacht",
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
return {
|
return { primary: `${hours}h ${mins}m` };
|
||||||
primary: `${hours}h ${mins}m`,
|
|
||||||
suffix: "per night",
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SleepOverview() {
|
export function SleepOverview() {
|
||||||
@@ -106,10 +100,11 @@ export function SleepOverview() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const averageMinutes = sleepSummary?.avg30 ?? sleepSummary?.avg7 ?? null;
|
const averageMinutes = sleepSummary?.avg30 ?? sleepSummary?.avg7 ?? null;
|
||||||
const { primary, suffix } =
|
const suffix = t("insights.sleep.headlineCaptionSuffix");
|
||||||
|
const { primary } =
|
||||||
averageMinutes != null
|
averageMinutes != null
|
||||||
? formatHoursMinutes(averageMinutes, locale)
|
? formatHoursMinutes(averageMinutes, locale)
|
||||||
: { primary: "—", suffix: "" };
|
: { primary: "—" };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
|
|||||||
Reference in new issue
Block a user