import type { Locale } from './types' /** * Resolves a bilingual label for the active locale. Falls back to the * opposite language when the preferred one is missing/empty, then to the * provided fallback, so callers never render an empty string. */ export function pickLocaleLabel( fr: string | undefined, en: string | undefined, locale: Locale, fallback = '', ): string { if (locale === 'en') return en || fr || fallback return fr || en || fallback } /** The same rule for a `{ fr, en }` label of the sheet or a snapshot ('' when absent). */ export function pickLabel( text: { fr?: string; en?: string } | null | undefined, locale: Locale, ): string { return pickLocaleLabel(text?.fr, text?.en, locale) }