Skip to content
GitHub

ParamLocalizationKey

type alias in meocord/common Since 4.3.0

type ParamLocalizationKey<C> =
  IsUntypedCatalog<C> extends true
    ? UntypedCatalogKey
    : {
        [K in StringMessageKey<C>]: [ParamNames<MessageAt<C, K>>] extends [
          never,
        ]
          ? never
          : K
      }[StringMessageKey<C>]

The keys Translator.localizations takes with params: a single string with {params}, filled in every locale.

A translator typed Translator<any>, or by hand with messages typed string, has params the compiler can't read, so such a key is here too, beside LocalizationKey. For Translator<any> it is any string.

Examples

TypeScript
const enUS = defineCatalog({ ping: 'Pong!', lookup: { user: 'Show {mode} for a linked user' } })
const key: ParamLocalizationKey<typeof enUS> = 'lookup.user'

See also