defineCatalog
function in meocord/common Since 4.1.0
defineCatalog<const T extends CatalogShape>(catalog: CatalogDefinition<T>): TDeclares a message catalog, keeping each message's text as its type so the params it takes can be checked.
A default catalog declared apart from createTranslator needs it, or as const. Other locales compile without it,
but only one that keeps its text has its {params} checked when the code compiles.
Parameters
| Name | Type | Description |
|---|---|---|
catalog | CatalogDefinition<T> | Messages, plurals and nested groups of them. |
Returns
TThe catalog, unchanged.
Examples
// src/locales/en-US.ts
export default defineCatalog({
ban: { description: 'Ban a member', done: 'Banned {user}.' },
warnings: { one: '{count} warning', other: '{count} warnings' },
})