@fluent/bundle
Version:
Localization library for expressive translations.
78 lines (77 loc) • 2.43 kB
TypeScript
/**
* @overview
*
* The FTL resolver ships with a number of functions built-in.
*
* Each function take two arguments:
* - args - an array of positional args
* - opts - an object of key-value args
*
* Arguments to functions are guaranteed to already be instances of
* `FluentValue`. Functions must return `FluentValues` as well.
*/
import { FluentValue } from "./types.js";
/**
* The implementation of the `NUMBER()` builtin available to translations.
*
* Translations may call the `NUMBER()` builtin in order to specify formatting
* options of a number. For example:
*
* pi = The value of π is {NUMBER($pi, maximumFractionDigits: 2)}.
*
* The implementation expects an array of {@link FluentValue | FluentValues} representing the
* positional arguments, and an object of named {@link FluentValue | FluentValues} representing the
* named parameters.
*
* The following options are recognized:
*
* unitDisplay
* currencyDisplay
* useGrouping
* minimumIntegerDigits
* minimumFractionDigits
* maximumFractionDigits
* minimumSignificantDigits
* maximumSignificantDigits
*
* Other options are ignored.
*
* @param args The positional arguments passed to this `NUMBER()`.
* @param opts The named argments passed to this `NUMBER()`.
*/
export declare function NUMBER(args: Array<FluentValue>, opts: Record<string, FluentValue>): FluentValue;
/**
* The implementation of the `DATETIME()` builtin available to translations.
*
* Translations may call the `DATETIME()` builtin in order to specify
* formatting options of a number. For example:
*
* now = It's {DATETIME($today, month: "long")}.
*
* The implementation expects an array of {@link FluentValue | FluentValues} representing the
* positional arguments, and an object of named {@link FluentValue | FluentValues} representing the
* named parameters.
*
* The following options are recognized:
*
* dateStyle
* timeStyle
* fractionalSecondDigits
* dayPeriod
* hour12
* weekday
* era
* year
* month
* day
* hour
* minute
* second
* timeZoneName
*
* Other options are ignored.
*
* @param args The positional arguments passed to this `DATETIME()`.
* @param opts The named argments passed to this `DATETIME()`.
*/
export declare function DATETIME(args: Array<FluentValue>, opts: Record<string, FluentValue>): FluentValue;