message-format-wg icon indicating copy to clipboard operation
message-format-wg copied to clipboard

Add Resource data model

Open eemeli opened this issue 4 years ago • 1 comments

This PR adds the data model for message resources and groups, i.e. groupings and hierarchical structures of messages. It refers to the Message data type, which is defined in #195.

As requested by @mihnita in the message data model PR, the interfaces' abstract data types are defined separately from their canonical JSON representations, and the metadata is left out. It is my belief that later work with the specification will indicate that it's simpler to merge these definitions, without creating a cost for implementations that choose to use a different internal representation than the canonical JSON.

I am aware of PR #203, and would be happy to work on a design document for this as well as other PRs, once it's defined what that ought to look like and if such a document is desired for this PR.

In my own code, these interfaces are defined here. The generic type parameter is used by the PatternMessage and SelectMessage interfaces to narrow down the pattern element types appropriately. In actual formatting use, these types are used by ResourceReader, which provides a more limited interface; this allows for e.g. non-enumerable message resources to be accessed. The ResourceReader API is in turn used by the getMessage() method of MessageFormat.

In addition to formatting, Resource is also used by @messageformat/compiler when converting MF1 and Fluent messages to MF2, and by @messageformat/xliff during conversion to and from XLIFF 2.

eemeli avatar Oct 11 '21 02:10 eemeli

Updated to match corresponding changes made to PR #195.

eemeli avatar Oct 11 '21 18:10 eemeli

Closing as out of date after #307

eemeli avatar Oct 24 '22 16:10 eemeli