Skip to content

Commit

Permalink
Update examples to match syntax changes
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Jun 28, 2022
1 parent e329774 commit 06d7780
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ and the plural rules of the current locale.
In a message resource, this could be defined using syntax such as:

```ini
# Note! MF2 syntax is still under development; this is likely to change
new_notifications [$count] =
[0] You have no new notifications
[one] You have one new notification
[_] You have {$count} new notifications
# Note! MF2 syntax is still under development; this may still change

new_notifications =
match {$count}
when 0 {You have no new notifications}
when one {You have one new notification}
when * {You have {$count} new notifications}
```

Some parts of the full message are explicitly repeated for each case,
Expand Down Expand Up @@ -198,7 +200,7 @@ may be used in the `values` argument as partially formatted values.
```ts
interface LocaleContext {
locales: string[];
localeMatcher: "best fit" | "lookup" | undefined;
localeMatcher: 'best fit' | 'lookup' | undefined;
}

interface MessageValue {
Expand All @@ -211,32 +213,32 @@ interface MessageValue {
}

interface MessageLiteral extends MessageValue {
type: "literal";
type: 'literal';
value: string;
}

interface MessageNumber extends MessageValue {
type: "number";
type: 'number';
value: number | bigint;
options?: Intl.NumberFormatOptions & Intl.PluralRulesOptions;
getPluralRule(): Intl.LDMLPluralRule;
toParts(): Intl.NumberFormatPart[];
}

interface MessageDateTime extends MessageValue {
type: "datetime";
type: 'datetime';
value: Date;
options?: Intl.DateTimeFormatOptions;
toParts(): Intl.DateTimeFormatPart[];
}

interface MessageFallback extends MessageValue {
type: "fallback";
type: 'fallback';
value: undefined;
}

interface ResolvedMessage extends MessageValue {
type: "message";
type: 'message';
value: Iterable<MessageValue>;
}
```
Expand Down

0 comments on commit 06d7780

Please sign in to comment.