mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-07 04:12:04 +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.",
|
||||
"headlineTitle": "Durchschnitt pro Nacht",
|
||||
"headlineCaption": "Gemittelt über {count} Nächte – {suffix}",
|
||||
"headlineCaptionSuffix": "pro Nacht",
|
||||
"compositionTitle": "Phasen-Verteilung",
|
||||
"compositionSubtitle": "Letzte {nights} Nächte",
|
||||
"compositionAriaLabel": "Schlafphasen-Verteilung über {nights} Nächte",
|
||||
|
||||
@@ -1081,6 +1081,7 @@
|
||||
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
||||
"headlineTitle": "Average per night",
|
||||
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
||||
"headlineCaptionSuffix": "per night",
|
||||
"compositionTitle": "Stage composition",
|
||||
"compositionSubtitle": "Last {nights} nights",
|
||||
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
||||
|
||||
@@ -1081,6 +1081,7 @@
|
||||
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
||||
"headlineTitle": "Average per night",
|
||||
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
||||
"headlineCaptionSuffix": "por noche",
|
||||
"compositionTitle": "Stage composition",
|
||||
"compositionSubtitle": "Last {nights} nights",
|
||||
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
||||
|
||||
@@ -1081,6 +1081,7 @@
|
||||
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
||||
"headlineTitle": "Average per night",
|
||||
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
||||
"headlineCaptionSuffix": "par nuit",
|
||||
"compositionTitle": "Stage composition",
|
||||
"compositionSubtitle": "Last {nights} nights",
|
||||
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
||||
|
||||
@@ -1081,6 +1081,7 @@
|
||||
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
||||
"headlineTitle": "Average per night",
|
||||
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
||||
"headlineCaptionSuffix": "per notte",
|
||||
"compositionTitle": "Stage composition",
|
||||
"compositionSubtitle": "Last {nights} nights",
|
||||
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
||||
|
||||
@@ -1081,6 +1081,7 @@
|
||||
"description": "Stage breakdown and nightly duration, drawn from Apple Health.",
|
||||
"headlineTitle": "Average per night",
|
||||
"headlineCaption": "Averaged across {count} nights — {suffix}",
|
||||
"headlineCaptionSuffix": "na noc",
|
||||
"compositionTitle": "Stage composition",
|
||||
"compositionSubtitle": "Last {nights} nights",
|
||||
"compositionAriaLabel": "Sleep stage composition over {nights} nights",
|
||||
|
||||
@@ -53,19 +53,13 @@ interface SleepAnalyticsResponse {
|
||||
function formatHoursMinutes(
|
||||
totalMinutes: number,
|
||||
locale: string,
|
||||
): { primary: string; suffix: string } {
|
||||
): { primary: string } {
|
||||
const hours = Math.floor(totalMinutes / 60);
|
||||
const mins = Math.round(totalMinutes - hours * 60);
|
||||
if (locale === "de") {
|
||||
return {
|
||||
primary: `${hours} Std. ${mins} Min.`,
|
||||
suffix: "pro Nacht",
|
||||
};
|
||||
return { primary: `${hours} Std. ${mins} Min.` };
|
||||
}
|
||||
return {
|
||||
primary: `${hours}h ${mins}m`,
|
||||
suffix: "per night",
|
||||
};
|
||||
return { primary: `${hours}h ${mins}m` };
|
||||
}
|
||||
|
||||
export function SleepOverview() {
|
||||
@@ -106,10 +100,11 @@ export function SleepOverview() {
|
||||
}
|
||||
|
||||
const averageMinutes = sleepSummary?.avg30 ?? sleepSummary?.avg7 ?? null;
|
||||
const { primary, suffix } =
|
||||
const suffix = t("insights.sleep.headlineCaptionSuffix");
|
||||
const { primary } =
|
||||
averageMinutes != null
|
||||
? formatHoursMinutes(averageMinutes, locale)
|
||||
: { primary: "—", suffix: "" };
|
||||
: { primary: "—" };
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
|
||||
Reference in new issue
Block a user