Skip to content
GitHub

LocalizationParams

type alias in meocord/common Since 4.3.0

type LocalizationParams<M> = Record<ParamNames<M>, LocalizationParam>

The params Translator.localizations fills into a message, one per {name} placeholder of the message M.

A message typed string, as in a translator typed Translator<any> or typed by hand from a JSON file's shape, takes any params. Use it to type params a helper builds before passing them on.

Examples

TypeScript
const enUS = defineCatalog({ lookup: { user: 'Show {mode} for a linked user' }, modes: { chaos: 'Chaos mode' } })
const t = createTranslator({ default: 'en-US', locales: { 'en-US': enUS } })

const params: LocalizationParams<typeof enUS.lookup.user> = { mode: locale => t.locale(locale)('modes.chaos') }
t.localizations('lookup.user', params)

See also