62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
// 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 -- the page itself holds no string.
|
|
//
|
|
// `t` takes a key relative to the module (`form.create`); the page binds it to
|
|
// `i18n.message("notes." + key)`.
|
|
|
|
import type { AttachmentLabels } from "./attachments.js"
|
|
import type { DeleteNoteLabels } from "./delete-note.js"
|
|
|
|
export type Translate = (key: string, values?: Record<string, string | number>) => string
|
|
|
|
export function resourceLabels(t: Translate) {
|
|
return {
|
|
title: t("title"),
|
|
/** A note: the table's name. */
|
|
one: t("list.one"),
|
|
/** The create action, a whole message: a language agrees the adjective with the noun. */
|
|
new: t("list.new"),
|
|
empty: t("list.empty"),
|
|
note: t("list.note"),
|
|
titleField: t("list.title"),
|
|
body: t("list.body"),
|
|
attachments: t("list.attachments"),
|
|
updated: t("list.updated"),
|
|
}
|
|
}
|
|
|
|
export type NotesResourceLabels = ReturnType<typeof resourceLabels>
|
|
|
|
/** `count` and `sizeKb` keep their placeholders: the list is live, so the browser fills them in. */
|
|
export function attachmentLabels(t: Translate): AttachmentLabels {
|
|
return {
|
|
title: t("attachments.title"),
|
|
count: t("attachments.count"),
|
|
empty: t("attachments.empty"),
|
|
file: t("attachments.file"),
|
|
type: t("attachments.type"),
|
|
sizeHeading: t("attachments.size"),
|
|
sizeKb: t("attachments.sizeKb"),
|
|
actions: t("attachments.actions"),
|
|
download: t("attachments.download", { filename: "{filename}" }),
|
|
remove: t("attachments.remove", { filename: "{filename}" }),
|
|
removeShort: t("attachments.removeShort"),
|
|
removeConfirm: t("attachments.removeConfirm"),
|
|
off: t("attachments.off"),
|
|
uploadLabel: t("upload.label"),
|
|
uploadHint: t("upload.hint"),
|
|
uploadSubmit: t("upload.submit"),
|
|
uploadBusy: t("upload.busy"),
|
|
}
|
|
}
|
|
|
|
export function deleteLabels(t: Translate): DeleteNoteLabels {
|
|
return {
|
|
button: t("delete.button"),
|
|
confirm: t("delete.confirm"),
|
|
yes: t("delete.yes"),
|
|
no: t("delete.no"),
|
|
}
|
|
}
|