/** * Locale-aware walking-distance formatting. * * Distances are stored as Int meters. Under 1000 m they render as whole * meters, above that as kilometers with one decimal (e.g. "1.2 km"). Reused by * the tracking card, the team leaderboards and the profile distances. */ export function useFormatDistance() { const { locale } = useI18n(); function formatDistance(meters: number | null | undefined): string { const value = meters ?? 0; const loc = locale.value || 'en'; if (value < 1000) { return new Intl.NumberFormat(loc, { style: 'unit', unit: 'meter', maximumFractionDigits: 0 }).format(Math.round(value)); } return new Intl.NumberFormat(loc, { style: 'unit', unit: 'kilometer', maximumFractionDigits: 1 }).format(value / 1000); } return { formatDistance }; }