FakeMessageCatalogue
A scripted MessageCatalogue.
This is a class exported by @mapcairn/core, checked against version 0.2.0.
Signature
import { FakeMessageCatalogue } from "@mapcairn/core";
class FakeMessageCatalogue implements MessageCatalogue
Description
How to script it: pass overrides to change what a key resolves to, or
missingKeys to simulate a translation that lacks a key (falls back to
English and warns, like the real catalogue). calls records every t/
plural call in order, so a component test can assert on the key and
parameters a component asked for, rather than only on rendered text.
list is not scripted: it formats with Intl.ListFormat, the same as the
real catalogue, because it needs no catalogue lookup to fake.
Constructors
(constructor)
constructor(options?: FakeMessageCatalogueOptions);
Constructs a new instance of the FakeMessageCatalogue class
options?(FakeMessageCatalogueOptions)
Properties
calls
readonly calls: MessageCatalogueCall[];
Every t and plural call, in order, with its key and parameters.
definitionTexts
readonly definitionTexts?: Readonly<Record<string, string>>;
The host's definition text translations the fake was given, if any.
language
readonly get language(): string;
The language tag, en-GB unless the options say otherwise.
layerTemplates
readonly layerTemplates?: Readonly<Record<string, string>>;
The host's layer template translations the fake was given, if any.
list
list: (items: readonly string[], type?: "conjunction" | "disjunction") => string;
Joins the items with Intl.ListFormat. It is not recorded or scripted.
numberingSystem
readonly get numberingSystem(): string | undefined;
The Intl numbering system the fake was given, or undefined.
plural
plural: <K extends MessageKey>(key: K, params: MessageParams[K] & {
readonly count: number;
}) => string;
Records the call, then returns the form of the text that the count selects.
t
t: <K extends MessageKey>(key: K, params: MessageParams[K]) => string;
Records the call, then returns the catalogue text for the key with its parameters filled in.