UNPKG

@messageformat/icu-messageformat-1

Version:

Compile ICU MessageFormat 1 sources into MessageFormat 2 formatters

64 lines (63 loc) 2.61 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 date(ctx: MessageFunctionContext, options: Record<string, unknown>, operand?: unknown): MessageDateTime; declare function time(ctx: MessageFunctionContext, options: Record<string, unknown>, operand?: unknown): MessageDateTime; declare function duration(_ctx: MessageFunctionContext, _options: unknown, operand?: unknown): { type: "mf1:duration"; toParts: () => [{ readonly type: "mf1:duration"; 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.date}, * used for formatting `date` placeholders. */ 'mf1:date': typeof date; /** * A wrapper around {@link DraftFunctions.time}, * used for formatting `time` placeholders. */ 'mf1:time': typeof time; /** * 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 {};