/** * A formatter receives the raw `data` value, parsed options from the * placeholder, and the resolved locale, and returns the substituted string. * Register one via `Ilingo.registerFormatter(name, fn)` or the * `Options.formatters` constructor option; the built-ins are `number`, * `date`, and `list`. */ export type Formatter = (value: unknown, options: Record, locale: string) => string; export type FormatterOptions = Record; /** * Parse the options-string segment of a template modifier. * * `currency=EUR, style=currency, minimumFractionDigits=2` * → `{ currency: 'EUR', style: 'currency', minimumFractionDigits: 2 }` * * Numbers and booleans are auto-coerced; everything else stays a string. */ export declare function parseFormatterOptions(input: string | undefined): FormatterOptions; export declare function parseModifier(input: string): { name: string; options: string | undefined; } | undefined; /** * Per-instance formatter registry. Caches `Intl.*Format` instances keyed by * `(formatter, locale, JSON-encoded options)` so repeated template renders * don't reallocate. */ export declare class FormatterRegistry { protected entries: Map; protected cache: Map; constructor(); register(name: string, formatter: Formatter): void; get(name: string): Formatter | undefined; has(name: string): boolean; /** * Look up or construct the `Intl.*Format` instance for `(kind, locale, * options)`. Returns `undefined` if either the cache-key generation or * the constructor throws — built-in formatters then fall back to a plain * `String(value)` rendering rather than letting a typo in a translator's * options crash the entire render. * * Options are stringified with sorted keys so callers that happen to pass * the same logical options in a different order share a cache entry. */ protected intl(kind: string, locale: string, options: FormatterOptions, create: () => T): T | undefined; }