Intl.MessageResource ?
- Stage: Unstaged
- Status: Active
- ECMAScript edition: —
- Synchronized: Aug 28, 2026
- 中文译文 · Source repository
This proposal extends the Intl.MessageFormat proposal by adding a static parseResource() method to parse entire message resources (bundles) at once, not just individual messages. It introduces a MessageResource type as a Map of MessageFormat instances, supporting flat or hierarchical message organization.
The README below comes from the upstream repository and may contain outdated stage or status metadata. Use the proposal details above as the current source of truth.
Intl.MessageFormat.parseResource()
This is a follow-on proposal to the Intl.MessageFormat proposal, adding support for handling entire resources (aka bundles) of messages, in addition to supporting individual messages.
Status
Champion: Eemeli Aro (Mozilla/OpenJS Foundation)
Stage: 1
Motivation and Use Cases
In most use cases, systems that have a need to format messages need to format more than one such message. For example, a dialog box may include a title, description, and one or more buttons with labels. These messages need to be handled together as a cohesive unit, both when editing or translating, as well as when formatting.
To enable this, a message resource syntax is being developed in parallel with the MessageFormat 2.0 specification.
This proposal adds a static method Intl.MessageFormat.parseResource() that allows for parsing such resources.
Such a method would allow for MF2 messages to be stored and transmitted in a purpose-built container,
rather than needing to be separately parsed for use in JavaScript environments.
API Description
As a baseline, this proposal presumes the existence of Intl.MessageFormat as described in its proposal,
and extends it.
MessageFormat.parseResource(resource, locales?, options?)
This static method parses a string representation of an MF2 resource,
constructing a Map with a corresponding structure of MessageFormat instances for each of the resource's messages.
Its locales and options arguments are used to construct each such instance.
A MessageResource is a Map representing a collection of related messages for a single locale.
Messages can be organized in a flat structure, or in hierarchy, using paths.
Conceptually, it is similar to a file containing a set of messages,
but there are no constrains implied on the underlying implementation.
Example
Given an MF2 resource as follows:
This could be used in code like this: