@@ -0,0 +1,83 @@
|
||||
// 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 (`products.name`); the page binds it to
|
||||
// `i18n.message("catalog." + key)`. The app's `app.failed` is passed in already looked up, and so is
|
||||
// `refusals`, the kit's text for each business refusal in the reader's language (`businessRefusalNotices`).
|
||||
|
||||
import type { ImportFormLabels } from "./import-form.js"
|
||||
import type { ImportListLabels } from "./import-list.js"
|
||||
import type { ProductListLabels } from "./product-list.js"
|
||||
|
||||
export type Translate = (key: string, values?: Record<string, string | number>) => string
|
||||
export type Refusals = Readonly<Record<string, string>>
|
||||
|
||||
export function productListLabels(t: Translate, failed: string, refusals: Refusals): ProductListLabels {
|
||||
return {
|
||||
caption: t("products.caption"),
|
||||
empty: t("products.empty"),
|
||||
code: t("products.code"),
|
||||
name: t("products.name"),
|
||||
unit: t("products.unit"),
|
||||
status: t("products.status"),
|
||||
// The placeholder is the component's to fill, so it is passed through untouched.
|
||||
open: t("products.open", { name: "{name}" }),
|
||||
search: t("products.search"),
|
||||
searchIn: t("products.searchIn"),
|
||||
fields: {
|
||||
name: t("products.byName"),
|
||||
code: t("products.byCode"),
|
||||
gtin: t("products.byGtin"),
|
||||
erp: t("products.byErp"),
|
||||
},
|
||||
searchSubmit: t("products.searchSubmit"),
|
||||
more: t("products.more"),
|
||||
failed,
|
||||
refusals,
|
||||
}
|
||||
}
|
||||
|
||||
export function importListLabels(t: Translate, count: number): ImportListLabels {
|
||||
return {
|
||||
count: t("imports.count", { count }),
|
||||
caption: t("imports.caption"),
|
||||
empty: t("imports.empty"),
|
||||
source: t("imports.source"),
|
||||
status: t("imports.status"),
|
||||
created: t("imports.created"),
|
||||
updated: t("imports.updated"),
|
||||
unchanged: t("imports.unchanged"),
|
||||
refused: t("imports.refused"),
|
||||
}
|
||||
}
|
||||
|
||||
export function importFormLabels(t: Translate, failed: string, refusals: Refusals): ImportFormLabels {
|
||||
return {
|
||||
heading: t("importForm.heading"),
|
||||
file: t("importForm.file"),
|
||||
hint: t("importForm.hint"),
|
||||
submit: t("importForm.submit"),
|
||||
busy: t("importForm.busy"),
|
||||
// The counts are the component's to fill, so the placeholders are passed through untouched.
|
||||
done: t("importForm.done", {
|
||||
created: "{created}",
|
||||
updated: "{updated}",
|
||||
unchanged: "{unchanged}",
|
||||
refused: "{refused}",
|
||||
}),
|
||||
empty: t("importForm.empty"),
|
||||
tooLarge: t("importForm.tooLarge"),
|
||||
missing: t("importForm.missing", { columns: "{columns}" }),
|
||||
refusedCaption: t("importForm.refusedCaption"),
|
||||
row: t("importForm.row"),
|
||||
reason: t("importForm.reason"),
|
||||
reasons: {
|
||||
invalid_fields: t("importForm.invalidFields"),
|
||||
conflict: t("importForm.conflict"),
|
||||
not_found: t("importForm.notFound"),
|
||||
},
|
||||
failed,
|
||||
refusals,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user