Link Search Menu Expand Document

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 numerical values.
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.
extendLocaleContext(orig, lc) (BETA) Create a new LocaleContext, using orig as a base.
parseMessage(src) (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 a placeholder. The order of the declarations is not relevant, but a valid message may not include a dependency loop amond them.
Expression (BETA) To resolve an Expression, 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.
MarkupEnd (BETA) An element indicating the end of a span of elements, starting from the most recent MarkupStart that has the same name.
MarkupStart (BETA) An element indicating the start of a span of further elements that should have some markup applied to them.
MessageFormatOptions (BETA)
Option (BETA) Expression and MarkupStart 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.
Placeholder (BETA) Wrapper for non-literal content.
Runtime (BETA) The runtime function registry available when resolving Expression elements.
RuntimeFunction (BETA)
RuntimeOptions (BETA) The second argument of runtime function calls is an options bag, with possible keys as defined by the RuntimeFunction options. 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 placeholders. 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.
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.
isExpression (BETA) Type guard for Expression pattern elements
isJunk (BETA) Type guard for Junk pattern elements
isLiteral (BETA) Type guard for Literal pattern elements
isMarkupEnd (BETA) Type guard for MarkupEnd pattern elements
isMarkupStart (BETA) Type guard for MarkupStart pattern elements
isMessage (BETA) A type guard for Message values
isPatternMessage (BETA) A type guard for PatternMessage values
isPlaceholder (BETA) Type guard for Placeholder pattern elements
isSelectMessage (BETA) A type guard for SelectMessage values
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.
ParseError (BETA)
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.
RuntimeType (BETA) Basic type checking is performed on option values.
Text (BETA) Top-level literal content.