messageformat package


Class Description
MessageDateTime (BETA) A child class of MessageValue for Date values.
MessageFallback (BETA) A child class of MessageValue for fallback values.
MessageFormat (BETA) Create a new message formatter.
MessageLiteral (BETA) A child class of MessageValue for values defined directly in the message data.
MessageMarkup (BETA) A child class of MessageValue for starting markup elements.
MessageNumber (BETA) A child class of MessageValue for numerical values.
MessageValue (BETA) The base class of all message values.
ResolvedMessage (BETA) The result of resolving a MessageFormat message.


Function Description
asMessageValue(ctx, value, format) (BETA) Convert any numerical value into a MessageNumber.
asMessageValue(ctx, value, format) (BETA) Convert any Date value into a MessageDateTime.
asMessageValue(ctx, value, format) (BETA) Convert any value into a MessageValue or one of its child classes.
castAsBoolean(options, names) (BETA) Utility function for custom functions. Cast resolved option values 'true' and 'false' to their Boolean equivalents. Any other values are untouched.
castAsInteger(options, names) (BETA) Utility function for custom functions. Cast resolved option values with numerical string representations of integers to their Number equivalents. Any other values are untouched.
extendLocaleContext(orig, lc) (BETA) Create a new LocaleContext, using orig as a base.
parseMessage(source, opt) (BETA) Parse the string syntax representation of a message into its corresponding data model representation.
stringifyMessage(msg) (BETA) Stringify a message using its syntax representation.
validate(msg, runtime) (BETA) Validate a message.


Interface Description
CatchallKey (BETA) The catch-all key matches all values.
Declaration (BETA) A message may declare any number of local variables or aliases, each with a value defined by an expression. The order of the declarations is not relevant, but a valid message may not include a dependency loop amond them.
Expression (BETA) Wrapper for non-literal content.
FunctionRef (BETA) To resolve a FunctionRef, an externally defined function is called.
Junk (BETA) When the parser encounters an error, it may emit a Junk pattern element to represent it.
JunkMessage (BETA) The result of parsing input that cannot be represented by a PatternMessage or a SelectMessage.
Literal (BETA) An immediately defined value.
LocaleContext (BETA) The minimum amount of information required to determine the locale to use when formatting a MessageValue.
MessageFormatOptions (BETA)
Option (BETA) FunctionRef options are expressed as key/value pairs to allow their order to be maintained.
Pattern (BETA) The body of each message is composed of a sequence of parts, some of them fixed (Text), others placeholders for values depending on additional data.
PatternMessage (BETA) A single message with no variants.
Reserved (BETA) When the parser encounters an expression with syntax reserved for later use, it emits a Reserved pattern element to represent it.
Runtime (BETA) The runtime function registry available when resolving FunctionRef elements.
RuntimeOptions (BETA) The second argument of runtime function calls is an options bag. The localeMatcher key is always present.
SelectMessage (BETA) SelectMessage generalises the plural, selectordinal and select argument types of MessageFormat 1. Each case is defined by a key of one or more string identifiers, and selection between them is made according to the values of a corresponding number of expressions. Selection iterates among the variants in order, and terminates when all of the Variant keys match. The result of the selection is always a single Pattern.
Text (BETA) Top-level literal content.
VariableRef (BETA) The value of a VariableRef is defined by the current Scope.
Variant (BETA)


Variable Description
defaultRuntime (BETA) The default Runtime includes two functions, datetime and number.
isCatchallKey (BETA) A type guard for CatchallKey values
isExpression (BETA) Type guard for Expression pattern elements
isFunctionRef (BETA) Type guard for FunctionRef pattern elements
isJunk (BETA) Type guard for Junk pattern elements
isLiteral (BETA) Type guard for Literal pattern elements
isMessage (BETA) A type guard for Message values
isPatternMessage (BETA) A type guard for PatternMessage values
isReserved (BETA) Type guard for Reserved pattern elements
isSelectMessage (BETA) A type guard for SelectMessage values
isText (BETA) Type guard for Text pattern elements
isVariableRef (BETA) Type guard for VariableRef pattern elements

Type Aliases

Type Alias Description
Message (BETA) The representation of a single message. The shape of the message is an implementation detail, and may vary for the same message in different languages.
Meta (BETA) Additional meta information may be attached to most nodes. In common use, this information is not required when formatting a message.
PatternElement (BETA) The contents of a message are a sequence of pattern elements, which may be immediately defined literal values, a reference to a value that depends on another message, the value of some runtime variable, or some function defined elsewhere.