Files
2026-11-14 09:56:45 +00:00

23 lines
1.0 KiB
TypeScript

import { businessRefusalNotices } from "@conusai-kit/business/refusals"
import type { Locale } from "@conusai-kit/i18n"
import { en as keys } from "../i18n/en.js"
export type LedgerMessages = { [K in keyof typeof keys]: string }
/**
* The module's messages, and every Ledger refusal's problem code with the sentence a person reads for it
* (the kit's, in the loader's locale; a revision or idempotency conflict in this module's own words). Plain
* strings, so the loader hands them to the forms, which read a refusal with `serviceNotice`.
*/
export type LedgerLabels = LedgerMessages & { readonly refusals: Readonly<Record<string, string>> }
export function ledgerLabels(t: (key: string) => string, locale: Locale): LedgerLabels {
const messages = Object.fromEntries(Object.keys(keys).map((key) => [key, t(key)])) as LedgerMessages
return {
...messages,
refusals: businessRefusalNotices(locale, {
revision_conflict: messages.revisionConflict,
idempotency_conflict: messages.idempotencyConflict,
}),
}
}