UNPKG

intl-messageformat

Version:

Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.

30 lines (29 loc) 1.47 kB
import { type MessageFormatElement, parse, type ParserOptions } from "@formatjs/icu-messageformat-parser"; import { type Formats, type Formatters, type FormatXMLElementFn, type MessageFormatPart, type PrimitiveType } from "./formatters.js"; export interface Options extends Omit<ParserOptions, "locale"> { formatters?: Formatters; } export declare class IntlMessageFormat { private readonly ast; private readonly locales; private readonly resolvedLocale?; private readonly formatters; private readonly formats; private readonly message; private readonly formatterCache; constructor(message: string | MessageFormatElement[], locales?: string | string[], overrideFormats?: Partial<Formats>, opts?: Options); format: <T = void>(values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>) => string | T | (string | T)[]; formatToParts: <T>(values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>) => MessageFormatPart<T>[]; resolvedOptions: () => { locale: string; }; getAst: () => MessageFormatElement[]; private static memoizedDefaultLocale; static get defaultLocale(): string; static resolveLocale: (locales: string | string[]) => Intl.Locale | undefined; static __parse: typeof parse | undefined; // Default format options used as the prototype of the `formats` provided to the // constructor. These are used when constructing the internal Intl.NumberFormat // and Intl.DateTimeFormat instances. static formats: Formats; }