feat(locales): add pluralization support for workout translations in multiple languages to enhance localization

refactor(workout-session-heatmap): simplify props destructuring and improve tooltip content generation for workout counts
This commit is contained in:
Mathias
2025-07-12 11:56:35 +02:00
7 changed files with 43 additions and 56 deletions
+2
View File
@@ -1817,5 +1817,7 @@ export default {
no_workout: "No workout",
one_workout_unit: "workout",
multiple_workouts_unit: "workouts",
"workout#one": "workout",
"workout#other": "workouts",
},
} as const;
+21 -22
View File
@@ -1802,30 +1802,29 @@ export default {
},
heatmap: {
week_days_short: {
sunday: "S",
monday: "L",
tuesday: "M",
wednesday: "M",
thursday: "J",
friday: "V",
saturday: "S",
sunday: "D", // domingo
monday: "L", // lunes
tuesday: "M", // martes
wednesday: "M", // miércoles
thursday: "J", // jueves
friday: "V", // viernes
saturday: "S", // sábado
},
month_names_short: {
january: "Ene",
february: "Feb",
march: "Mar",
april: "Abr",
may: "May",
june: "Jun",
july: "Jul",
august: "Aug",
september: "Sep",
october: "Oct",
november: "Nov",
december: "Dec",
january: "Ene", // enero
february: "Feb", // febrero
march: "Mar", // marzo
april: "Abr", // abril
may: "May", // mayo (same)
june: "Jun", // junio
july: "Jul", // julio
august: "Ago", // agosto
september: "Sep", // septiembre
october: "Oct", // octubre
november: "Nov", // noviembre
december: "Dic", // diciembre
},
no_workout: "No workout",
one_workout_unit: "workout",
multiple_workouts_unit: "workouts",
"workout#one": "entrenamiento",
"workout#other": "entrenamientos",
},
} as const;
+9 -10
View File
@@ -1818,13 +1818,13 @@ export default {
},
heatmap: {
week_days_short: {
sunday: "L",
monday: "M",
tuesday: "M",
wednesday: "J",
thursday: "V",
friday: "S",
saturday: "D",
sunday: "D", // dimanche
monday: "L", // lundi
tuesday: "M", // mardi
wednesday: "M", // mercredi
thursday: "J", // jeudi
friday: "V", // vendredi
saturday: "S", // samedi
},
month_names_short: {
january: "Jan",
@@ -1840,8 +1840,7 @@ export default {
november: "Nov",
december: "Déc",
},
no_workout: "No workout",
one_workout_unit: "workout",
multiple_workouts_unit: "workouts",
"workout#one": "séance",
"workout#other": "séances",
},
} as const;
+2 -3
View File
@@ -1824,8 +1824,7 @@ export default {
november: "Nov",
december: "Dez",
},
no_workout: "No workout",
one_workout_unit: "workout",
multiple_workouts_unit: "workouts",
"workout#one": "treino",
"workout#other": "treinos",
},
} as const;
+2 -3
View File
@@ -1815,8 +1815,7 @@ export default {
november: "Ноя",
december: "Дек",
},
no_workout: "No workout",
one_workout_unit: "workout",
multiple_workouts_unit: "workouts",
"workout#one": "тренировка",
"workout#other": "тренировок",
},
} as const;
+2 -3
View File
@@ -1760,8 +1760,7 @@ export default {
november: "十一月",
december: "十二月",
},
no_workout: "No workout",
one_workout_unit: "workout",
multiple_workouts_unit: "workouts",
"workout#one": "次训练",
"workout#other": "次训练",
},
} as const;
@@ -24,11 +24,7 @@ const MONTH_LABEL_HEIGHT = 18;
const MIN_COLUMNS = 10;
const MAX_COLUMNS = 53;
export const WorkoutSessionHeatmap: React.FC<Props> = ({
panelColors = DEFAULT_PANEL_COLORS,
values,
until,
}) => {
export const WorkoutSessionHeatmap: React.FC<Props> = ({ panelColors = DEFAULT_PANEL_COLORS, values, until }) => {
const t = useI18n();
const currentLocale = useCurrentLocale();
const containerRef = useRef<HTMLDivElement>(null);
@@ -44,9 +40,9 @@ export const WorkoutSessionHeatmap: React.FC<Props> = ({
// Create a locale-specific date formatter for tooltips
const formatDate = (date: dayjs.Dayjs) => {
return new Intl.DateTimeFormat(currentLocale, {
year: 'numeric',
month: 'short',
day: 'numeric'
year: "numeric",
month: "short",
day: "numeric",
}).format(date.toDate());
};
@@ -132,16 +128,10 @@ export const WorkoutSessionHeatmap: React.FC<Props> = ({
const dateStr = formatDate(d);
// Create tooltip content based on workout count
const getWorkoutText = (count: number): string => {
if (count === 0) return t("heatmap.no_workout");
if (count === 1) return `${count} ${t("heatmap.one_workout_unit")}`;
return `${count} ${t("heatmap.multiple_workouts_unit")}`;
};
const createTooltip = (workoutCount: number, date: string) => (
<div className="text-xs text-slate-50">
{date} : <br />
{getWorkoutText(workoutCount)}
{workoutCount} {t("heatmap.workout", { count: workoutCount })}
</div>
);