@@ -0,0 +1,125 @@
|
||||
// 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 (`documents.title`); the page binds it to
|
||||
// `i18n.message("archive." + key)`. The app's `app.failed` is passed in already looked up, and so is
|
||||
// `refusals`, the kit's sentence for each business refusal by problem code (`businessRefusalNotices`).
|
||||
|
||||
import { RETENTION_BASES, type RetentionClassView } from "../contract/index.js"
|
||||
import type { DocumentActionsLabels } from "./document-actions.js"
|
||||
import type { DocumentListLabels } from "./document-list.js"
|
||||
import type { RegisterFormLabels } from "./register-form.js"
|
||||
import type { RetentionLabels } from "./retention-classes.js"
|
||||
import type { RetentionFormLabels } from "./retention-form.js"
|
||||
import type { VersionFormLabels } from "./version-form.js"
|
||||
import type { VersionsLabels } from "./versions.js"
|
||||
|
||||
export type Translate = (key: string, values?: Record<string, string | number>) => string
|
||||
|
||||
/** The kit's sentence for each business refusal by problem code (`businessRefusalNotices` of `@conusai-kit/business/refusals`). */
|
||||
export type Refusals = Readonly<Record<string, string>>
|
||||
|
||||
export const baseNames = (t: Translate): Readonly<Record<RetentionClassView["from"], string>> =>
|
||||
Object.fromEntries(RETENTION_BASES.map((base) => [base, t(`retention.bases.${base}`)])) as Record<
|
||||
RetentionClassView["from"],
|
||||
string
|
||||
>
|
||||
|
||||
export function documentListLabels(t: Translate, failed: string, refusals: Refusals): DocumentListLabels {
|
||||
return {
|
||||
caption: t("documents.caption"),
|
||||
empty: t("documents.empty"),
|
||||
title: t("documents.title"),
|
||||
retentionClass: t("documents.retentionClass"),
|
||||
status: t("documents.status"),
|
||||
created: t("documents.created"),
|
||||
// The placeholder is the component's to fill, so it is passed through untouched.
|
||||
open: t("documents.open", { title: "{title}" }),
|
||||
search: t("documents.search"),
|
||||
searchSubmit: t("documents.searchSubmit"),
|
||||
more: t("documents.more"),
|
||||
failed,
|
||||
refusals,
|
||||
}
|
||||
}
|
||||
|
||||
export function registerFormLabels(t: Translate, failed: string, refusals: Refusals): RegisterFormLabels {
|
||||
return {
|
||||
heading: t("register.heading"),
|
||||
title: t("register.title"),
|
||||
kind: t("register.kind"),
|
||||
kindHint: t("register.kindHint"),
|
||||
retentionClass: t("register.retentionClass"),
|
||||
file: t("register.file"),
|
||||
submit: t("register.submit"),
|
||||
busy: t("register.busy"),
|
||||
noClass: t("register.noClass"),
|
||||
failed,
|
||||
refusals,
|
||||
}
|
||||
}
|
||||
|
||||
export function versionsLabels(t: Translate, count: number): VersionsLabels {
|
||||
return {
|
||||
title: t("versions.title"),
|
||||
count: t("versions.count", { count }),
|
||||
caption: t("versions.caption"),
|
||||
sequence: t("versions.sequence"),
|
||||
mediaType: t("versions.mediaType"),
|
||||
size: t("versions.size"),
|
||||
hash: t("versions.hash"),
|
||||
created: t("versions.created"),
|
||||
}
|
||||
}
|
||||
|
||||
export function versionFormLabels(t: Translate, failed: string, refusals: Refusals): VersionFormLabels {
|
||||
return {
|
||||
heading: t("versionForm.heading"),
|
||||
file: t("versionForm.file"),
|
||||
submit: t("versionForm.submit"),
|
||||
busy: t("versionForm.busy"),
|
||||
failed,
|
||||
refusals,
|
||||
}
|
||||
}
|
||||
|
||||
export function documentActionsLabels(t: Translate, failed: string, refusals: Refusals): DocumentActionsLabels {
|
||||
return {
|
||||
heading: t("actions.heading"),
|
||||
hold: t("actions.hold"),
|
||||
release: t("actions.release"),
|
||||
dispose: t("actions.dispose"),
|
||||
disposeConfirm: t("actions.disposeConfirm"),
|
||||
busy: t("actions.busy"),
|
||||
failed,
|
||||
refusals,
|
||||
}
|
||||
}
|
||||
|
||||
export function retentionLabels(t: Translate): RetentionLabels {
|
||||
return {
|
||||
caption: t("retention.caption"),
|
||||
empty: t("retention.empty"),
|
||||
code: t("retention.code"),
|
||||
keepFor: t("retention.keepFor"),
|
||||
from: t("retention.from"),
|
||||
dueCaption: t("retention.dueCaption"),
|
||||
dueEmpty: t("retention.dueEmpty"),
|
||||
}
|
||||
}
|
||||
|
||||
export function retentionFormLabels(t: Translate, failed: string, refusals: Refusals): RetentionFormLabels {
|
||||
return {
|
||||
heading: t("retentionForm.heading"),
|
||||
code: t("retentionForm.code"),
|
||||
keepFor: t("retentionForm.keepFor"),
|
||||
keepForHint: t("retentionForm.keepForHint"),
|
||||
from: t("retentionForm.from"),
|
||||
submit: t("retentionForm.submit"),
|
||||
busy: t("retentionForm.busy"),
|
||||
bases: baseNames(t),
|
||||
failed,
|
||||
refusals,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user