Skip to content

Commit c58758a

Browse files
docs(mf2/messageformat): Update README
1 parent 35a84f1 commit c58758a

File tree

1 file changed

+42
-30
lines changed

1 file changed

+42
-30
lines changed

mf2/messageformat/README.md

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,63 @@
1-
# A Polyfill for Intl.MessageFormat
1+
# MessageFormat 2 for JavaScript
22

3-
This library provides a runtime for the [ECMA-402 Intl.MessageFormat proposal],
4-
which is built on top of the developing [Unicode MessageFormat 2.0 specification], "MF2".
3+
This library provides an implementation of the [ECMA-402 Intl.MessageFormat proposal],
4+
which is built on top of the [Unicode MessageFormat 2.0 specification] (MF2),
5+
developed by the [MessageFormat Working Group].
56

6-
[ecma-402 intl.messageformat proposal]: https://github.com/dminor/proposal-intl-messageformat/
7-
[unicode messageformat 2.0 specification]: https://github.com/unicode-org/message-format-wg
8-
9-
> **NOTE**: This means that the v4 release of the `messageformat` package has
10-
> an entirely different API compared to its earlier major releases,
11-
> which were built on top of ICU MessageFormat, aka "MF1".
12-
> For that,
13-
> please see [`@messageformat/core`](https://www.npmjs.com/package/@messageformat/core) instead.
7+
The API provided by this library is current as of the [LDML 46.1] (December 2024)G
8+
version of the MF2 specification.
149

15-
## Usage
10+
[ecma-402 intl.messageformat proposal]: https://github.com/dminor/proposal-intl-messageformat/
11+
[unicode messageformat 2.0 specification]: https://unicode.org/reports/tr35/tr35-messageFormat.html
12+
[messageformat working group]: https://github.com/unicode-org/message-format-wg
13+
[LDML 46.1]: https://www.unicode.org/reports/tr35/tr35-74/tr35-messageFormat.html
1614

1715
```sh
1816
npm install --save-exact messageformat@next
1917
```
2018

2119
```js
2220
import { MessageFormat } from 'messageformat';
23-
Intl.MessageFormat = MessageFormat;
21+
22+
const msg = 'Today is {$today :datetime dateStyle=medium}';
23+
const mf = new MessageFormat('en', msg);
24+
25+
mf.format({ today: new Date('2022-02-02') });
26+
// 'Today is Feb 2, 2022'
2427
```
2528

26-
In addition to supporting MF2 syntax,
27-
compilers and formatting function runtimes are also provided for
28-
ICU MessageFormat and Fluent messages:
29+
The library also provides a number of other tools and utilities for MF2, such as:
2930

30-
- [@messageformat/icu-messageformat-1](https://www.npmjs.com/package/@messageformat/icu-messageformat-1)
31-
- [@messageformat/fluent](https://www.npmjs.com/package/@messageformat/fluent)
31+
- MF2 data model conversion tools
3232

33-
## API
33+
```js
34+
import { parseMessage, stringifyMessage } from 'messageformat';
35+
```
3436

35-
The API provided by this Intl.MessageFormat polyfill is current as of
36-
[2022-07-13](https://github.com/tc39/proposal-intl-messageformat/blob/72eefa5/README.md).
37-
The static `MessageFormat.parseResource()` method is not yet provided,
38-
as the message resource syntax is still under development.
37+
- MF2 data model validation and transformation tools
3938

40-
```js
41-
const locale = 'en-US';
42-
const msg = '{Today is {$today :datetime dateStyle=medium}}';
39+
```js
40+
import { validate, visit } from 'messageformat';
41+
```
4342

44-
const mf = new Intl.MessageFormat(msg, locale);
43+
- Concreate Syntax Tree (CST) tools for MF2
44+
```js
45+
import { parseCST, messageFromCST, stringifyCST } from 'messageformat';
46+
```
4547

46-
mf.format({ today: new Date('2022-02-02') });
47-
// 'Today is Feb 2, 2022'
48-
```
48+
In addition to supporting MF2 syntax,
49+
compilers and formatting function runtimes are also provided for
50+
ICU MessageFormat and Fluent messages:
51+
52+
- [@messageformat/icu-messageformat-1](https://www.npmjs.com/package/@messageformat/icu-messageformat-1)
53+
- [@messageformat/fluent](https://www.npmjs.com/package/@messageformat/fluent)
4954

5055
For more information on additional types and functions provided by this package,
5156
see the [API documentation site](https://messageformat.github.io/messageformat/api/).
57+
58+
> [!IMPORTANT]
59+
> This means that the v4 release of the `messageformat` package has
60+
> an entirely different API compared to its earlier major releases,
61+
> which were built on top of ICU MessageFormat, aka "MF1".
62+
> For that,
63+
> please see [`@messageformat/core`](https://www.npmjs.com/package/@messageformat/core) instead.

0 commit comments

Comments
 (0)