Skip to main content

checkMessageCatalogue

Checks a host's message catalogue against the English one, for a host's own tests or a command line: every key is present and known, every form keeps all the English placeholders, the plural forms are the categories Intl.PluralRules gives for language, and no value is copied from English. A key is plural when it is in options.pluralKeys, or when its English value or the translation has forms (one|other or category-keyed, as createMessageCatalogue reads them) and it is not in options.notPlural; any other value is checked as text.

This is a function exported by @mapcairn/core, checked against version 0.2.0.

Signature​

import { checkMessageCatalogue } from "@mapcairn/core";

function checkMessageCatalogue(language: string, catalogue: Readonly<Partial<Record<string, string>>>, english: Readonly<Record<string, string>>, options?: MessageCatalogueCheckOptions): readonly MessageCatalogueProblem[];

Parameters​

  • language (string)
  • catalogue (Readonly<Partial<Record<string, string>>>)
  • english (Readonly<Record<string, string>>)
  • options? (MessageCatalogueCheckOptions): Keys allowed to match English, plural keys whose English value has no forms, and keys read only with t whose values only look plural. An entry that is not needed is reported, as is an allowance with a blank reason and a key in both key lists.

Returns​

readonly MessageCatalogueProblem[]: Every problem found: those of each English key in English key order, then unknown keys, then unneeded sameAsEnglish, pluralKeys and notPlural entries in that order, then keys in both key lists. An empty list means the catalogue passes; a translation in progress can leave out the missing problems. Keys are read only as a record's own properties.

See also​

Source: packages/core/src/messages/checkMessageCatalogue.ts:221