Skip to content

Commit

Permalink
Add section headings
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Feb 8, 2022
1 parent 287f87a commit 88b9c2a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ rather than relying upon userland libraries.
- The primary use case is the retrieval of localized text ("a message")
given a message identifier and a previously specified locale.

## Description

### API
## API Description

The MF2 specification is still being developed by the working group.
The API below is based upon one proposal under consideration,
Expand All @@ -39,6 +37,8 @@ In particular, the API shapes of
`MessageFormatOptions`, `MessageData`, `MessageResourceData`, and `ResolvedMessageFormatOptions`
will depend upon the data model chosen by the working group.

### MessageData and MessageResourceData

The `MessageData` and `MessageResourceData` interfaces will be defined by
the MF2 data model developed by the MF2 working group.
`MessageData` contains a parsed representation of a single message for a particular locale.
Expand All @@ -50,6 +50,8 @@ interface MessageData {}
interface MessageResourceData {}
```

### MessageResource

A `MessageResource` is a group 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,
Expand All @@ -74,6 +76,8 @@ interface MessageResource {
}
```

### MessageFormat

The `Intl.MessageFormat` constructor creates `MessageFormat` instances for a given locale,
`MessageFormatOptions` and an optional set of `MessageResource`s.
The remaining operations are defined on `MessageFormat` instances.
Expand Down Expand Up @@ -104,6 +108,8 @@ interface MessageFormat {
}
```

#### Constructor options and resolvedOptions()

The interfaces for
`MessageFormatOptions` and `ResolvedMessageFormatOptions`
will depend on the final MF2 data model.
Expand Down Expand Up @@ -137,6 +143,8 @@ type MessageFormatterFunction = (
) => MessageValue
```
#### format() and getMessage()
For formatting a message, two methods are provided: `format()` and `getMessage()`.
The first of these will always return a simple string,
while the latter returns a `ResolvedMessage` object or `undefined` if the message was not found.
Expand All @@ -151,6 +159,8 @@ These methods have the following arguments:
If `onError` is not defined,
errors will be ignored and a fallback representation used for the corresponding message part.
### MessageValue
`ResolvedMessage` is intended to provide a building block for the localization of messages
in contexts where its representation as a plain string would not be sufficient.
The `source` of a `MessageValue` provides an opaque identifier for the value,
Expand Down

0 comments on commit 88b9c2a

Please sign in to comment.