Skip to content
GitHub

TranslatorOptions

type alias in meocord/common Since 4.1.0

type TranslatorOptions<
  Locales extends Readonly<Record<string, CatalogShape>>,
  Default extends keyof Locales & `${Locale}`,
> = {
  default: Default
  locales: Locales &
    DiscordLocaleKeys<Locales> & {
      readonly [L in Exclude<keyof Locales, Default>]: WithinDefault<
        Locales[L],
        Locales[Default]
      >
    }
} & LiteralCatalog<Locales[Default]> &
  MeoCordReport<
    { [L in keyof Locales]: CatalogIssues<Locales[L]> }[keyof Locales]
  > &
  MeoCordReport<
    {
      [L in Exclude<keyof Locales, Default>]: LocaleIssues<
        Locales[L],
        Locales[Default],
        L & string
      >
    }[Exclude<keyof Locales, Default>]
  >

What createTranslator takes: the default locale, and a catalog per locale.

It is checked as it is written. Every key of locales is a locale Discord sends, every catalog holds only messages the default one has, using no {param} the default's lacks, and the default catalog keeps its messages' text, so their params are read from it. Each catalog's meocord group is checked as CatalogDefinition checks it. A mistake shows as an error naming the locale or the message.