// The labels each component takes, built from a message lookup. Every key this module's pages use // is named here and nowhere else, so `__tests__/i18n.test.ts` can run these builders against the // catalogues and fail on a key either language lacks. export type Translate = (key: string, values?: Record) => string /** The status shape the labels render, declared here: ui reads no core/. */ interface StatusCounts { documents: { queued: number; indexing: number; indexed: number; failed: number; cancelled: number } } export interface StatusLabels { readonly heading: string readonly flagOff: string readonly state: string readonly reasons: string readonly indexing: string readonly documents: string } export function statusLabels(t: Translate, status: StatusCounts): StatusLabels { return { heading: t("status.heading"), flagOff: t("status.flagOff"), state: t("status.state"), reasons: t("status.reasons"), indexing: t("status.indexing"), documents: t("status.documents", status.documents), } } export const serviceStateLabel = (t: Translate, state: string): string => { switch (state) { case "ready": return t("status.stateReady") case "indexing": return t("status.stateIndexing") case "registered": return t("status.stateRegistered") case "degraded": return t("status.stateDegraded") case "disabled": return t("status.stateDisabled") default: return t("status.stateUnavailable") } } export interface SearchFormLabels { readonly heading: string readonly label: string readonly placeholder: string readonly submit: string readonly busy: string readonly empty: string readonly results: string readonly snippet: string readonly source: string readonly chunk: string readonly disclosure: string readonly failed: string } export function searchFormLabels(t: Translate, failed: string): SearchFormLabels { return { heading: t("search.heading"), label: t("search.label"), placeholder: t("search.placeholder"), submit: t("search.submit"), busy: t("search.busy"), empty: t("search.empty"), results: t("search.results", { count: "{count}" }), snippet: t("search.snippet"), source: t("search.source"), chunk: t("search.chunk", { chunk: "{chunk}" }), disclosure: t("search.disclosure"), failed, } }