Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions spec/formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,12 @@ Earlier _selectors_ in the _matcher_'s list of _selectors_ have a higher priorit
When all of the _selectors_ have been processed,
the earliest-sorted _variant_ in the remaining list of _variants_ is selected.

> [!NOTE]
> A _selector_ _expression_ is not a _declaration_,
> and its _annotation_ has no effect on the value of its _operand_ during formatting.
> To use the same value for selection and formatting,
> set its value with a `.input` or `.local` _declaration_.

This selection method is defined in more detail below.
An implementation MAY use any pattern selection method,
as long as its observable behavior matches the results of the method defined here.
Expand Down Expand Up @@ -692,10 +698,11 @@ and an `en` (English) locale,
the pattern selection proceeds as follows for this message:

```
.match {$count :number}
one {{Category match}}
1 {{Exact match}}
* {{Other match}}
.input {$count :number}
.match {$count}
one {{Category match for {$count}}}
1 {{Exact match for {$count}}}
* {{Other match for {$count}}}
```

1. For the selector:<br>
Expand All @@ -716,7 +723,7 @@ one {{Category match}}
This is then sorted as:<br>
« ( 0, `1` ), ( 1, `one` ), ( 2, `*` ) »<br>

4. The pattern `Exact match` of the most preferred `1` variant is selected.
4. The pattern `Exact match for {$count}` of the most preferred `1` variant is selected.

## Formatting

Expand Down
7 changes: 5 additions & 2 deletions spec/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ match-statement = match 1*([s] selector)
> A _message_ with a _matcher_:
>
> ```
> .match {$count :number}
> .input {$count :number}
> .match {$count}
> one {{You have {$count} notification.}}
> * {{You have {$count} notifications.}}
> ```
Expand Down Expand Up @@ -408,7 +409,9 @@ There MAY be any number of additional _selectors_.
> A message with two _selectors_:
>
> ```
> .match {$numLikes :number} {$numShares :number}
> .input {$numLikes :number}
> .input {$numShares :number}
> .match {$numLikes} {$numShares}
> 0 0 {{Your item has no likes and has not been shared.}}
> 0 one {{Your item has no likes and has been shared {$numShares} time.}}
> 0 * {{Your item has no likes and has been shared {$numShares} times.}}
Expand Down