UNPKG

@messageformat/icu-messageformat-1

Version:

Compile ICU MessageFormat 1 sources into MessageFormat 2 formatters

60 lines (59 loc) 2.42 kB
import { type MessageDateTime, type MessageFunctionContext, type MessageNumber } from 'messageformat/functions'; declare function currency(ctx: MessageFunctionContext, options: Record<string, unknown>, operand?: unknown): MessageNumber; declare function datetime(ctx: MessageFunctionContext, options: Record<string, unknown>, operand?: unknown): MessageDateTime; declare function duration(ctx: MessageFunctionContext, _options: unknown, operand?: unknown): { type: "mf1:duration"; source: string; toParts: () => [{ readonly type: "mf1:duration"; readonly source: string; readonly value: string; }]; toString: () => string; valueOf: () => number; }; declare function number(ctx: MessageFunctionContext, options: Record<string, unknown>, operand?: unknown): MessageNumber; declare function plural(ctx: MessageFunctionContext, options: Record<string, unknown>, operand?: unknown): MessageNumber; declare function unit(ctx: MessageFunctionContext, options: Record<string, unknown>, operand?: unknown): MessageNumber; /** * Function handlers for ICU MessageFormat 1. * * Used by {@link mf1ToMessage}. */ export declare let MF1Functions: { /** * A wrapper around {@link DraftFunctions.currency}, * used for formatting a `number, currency` and `number, ::currency` placeholder. */ 'mf1:currency': typeof currency; /** * A wrapper around {@link DraftFunctions.datetime}, * used for formatting `date` and `time` placeholders. */ 'mf1:datetime': typeof datetime; /** * Formats a duration expressed as seconds. * * The formatted value includes one or two `:` separators, * matching the pattern `hhhh:mm:ss`, * possibly with a leading `-` for negative values and a trailing `.sss` part for non-integer input. */ 'mf1:duration': typeof duration; /** * A wrapper around {@link DefaultFunctions.number}, * used for formatting most `number` placeholders. */ 'mf1:number': typeof number; /** * A plural or selectordinal selector that includes an `offset`. * * Selectors without an offset are represented by `:number`. */ 'mf1:plural': typeof plural; /** * A wrapper around {@link DraftFunctions.unit}, * used for formatting `number, percent`, `number, ::unit`, and other placeholders. */ 'mf1:unit': typeof unit; }; export {};