Skip to content

Commit

Permalink
Use locales as first argument (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli authored May 6, 2024
1 parent e46d7e5 commit 0756aca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ In code, with the API proposed below, this would be used like this:

```js
const source = ... // string source of the message as above
const mf = new Intl.MessageFormat(source, 'en');
const mf = new Intl.MessageFormat('en', source);
const notifications = mf.format({ count: 1 });
// 'You have 1 new notification'
```
Expand All @@ -79,11 +79,11 @@ those are of course also supported by the proposed API:

```js
// A plain message
const mf1 = new Intl.MessageFormat('Hello!', 'en');
const mf1 = new Intl.MessageFormat('en', 'Hello!');
mf1.format(); // 'Hello!'

// A parametric message, formatted to parts
const mf2 = new Intl.MessageFormat('Hello {$place}!', 'en');
const mf2 = new Intl.MessageFormat('en', 'Hello {$place}!');
const greet = mf2.formatToParts({ place: 'world' });
/* [
{ type: 'text', value: 'Hello ' },
Expand Down Expand Up @@ -144,8 +144,8 @@ Calling the constructor may throw an error if the `source` includes an MF2
```ts
interface MessageFormat {
new (
locales: string | string[] | undefined,
source: MessageData | string,
locales?: string | string[],
options?: MessageFormatOptions
): MessageFormat;

Expand Down
Loading

0 comments on commit 0756aca

Please sign in to comment.