// The labels each component takes, built from a message lookup. Every key this module's pages use is // named here or in pages.tsx, so `__tests__/i18n.test.ts` can run these builders against the // catalogues and fail on a key either language lacks. // // `t` takes a key relative to the module (`form.submit`); the page binds it to // `i18n.message("inventory." + key)`. `refusals` is the kit's text for each business refusal in the reader's // language (`businessRefusalNotices`), which a form or a list shows when the service refuses. import type { ItemFormLabels } from "./item-form.js" import type { ItemListLabels } from "./item-list.js" import type { ReservationListLabels } from "./reservation-list.js" import type { ReserveFormLabels } from "./reserve-form.js" import type { StockLabels } from "./stock.js" export type Translate = (key: string, values?: Record) => string export type Refusals = Readonly> export function itemFormLabels(t: Translate, refusals: Refusals): ItemFormLabels { return { heading: t("form.heading"), sku: t("form.sku"), skuHint: t("form.skuHint"), name: t("form.name"), unit: t("form.unit"), unitHint: t("form.unitHint"), description: t("form.description"), submit: t("form.submit"), busy: t("form.busy"), refusals, } } export function itemListLabels(t: Translate): ItemListLabels { return { caption: t("items.caption"), empty: t("items.empty"), sku: t("items.sku"), name: t("items.name"), unit: t("items.unit"), active: t("items.active"), archived: t("items.archived"), // The placeholders are the component's to fill, so they are passed through untouched. open: t("items.open", { name: "{name}" }), search: t("items.search"), } } export function stockLabels(t: Translate, unit: string, locations: number): StockLabels { return { unit: t("item.unit", { unit }), locations: t("item.locations", { count: locations }), onHand: t("item.onHand"), reserved: t("item.reserved"), available: t("item.available"), caption: t("item.locationsCaption"), location: t("item.location"), none: t("item.none"), } } export function reserveFormLabels(t: Translate, refusals: Refusals): ReserveFormLabels { return { heading: t("reserve.heading"), location: t("reserve.location"), quantity: t("reserve.quantity"), submit: t("reserve.submit"), busy: t("reserve.busy"), nothing: t("reserve.nothing"), refusals, } } export function reservationListLabels(t: Translate, refusals: Refusals): ReservationListLabels { return { title: t("reservations.title"), caption: t("reservations.caption"), empty: t("reservations.empty"), item: t("reservations.item"), quantity: t("reservations.quantity"), outstanding: t("reservations.outstanding"), actions: t("reservations.actions"), release: t("reservations.release", { item: "{item}" }), releaseShort: t("reservations.releaseShort"), releasing: t("reservations.releasing"), releaseConfirm: t("reservations.releaseConfirm"), refusals, } }