Skip to content

Commit d7257e6

Browse files
authored
Remove non-registry functions and options from examples (#625)
* Remove non-registry functions and options from examples Fixes #569 Going through our specs to remove or repair examples so that they match the functions in the default registry. Some generic examples are retained, e.g. `:func` in errors.md where we want to focus the example on syntax rather than the registry. -- Errors.md: - fix `:number` options to be spelled out correctly - fix formatting error examples to use real functions * Update syntax.md * Update errors.md * Fix unnecessarily quoted simple messages * Update syntax.md * Update errors.md * Update syntax.md * Update formatting.md * Revert formatting errors example
1 parent 88bd7d1 commit d7257e6

File tree

3 files changed

+41
-52
lines changed

3 files changed

+41
-52
lines changed

spec/errors.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,19 @@ so explicitly declaring it after such use is also an error.
136136
> Examples of invalid messages resulting in a _Duplicate Declaration_ error:
137137
>
138138
> ```
139-
> .input {$var :number maxFractionDigits=0}
140-
> .input {$var :number minFractionDigits=0}
139+
> .input {$var :number maximumFractionDigits=0}
140+
> .input {$var :number minimumFractionDigits=0}
141141
> {{Redeclaration of the same variable}}
142142
>
143-
> .local $var = {$ext :number maxFractionDigits=0}
144-
> .input {$var :number minFractionDigits=0}
143+
> .local $var = {$ext :number maximumFractionDigits=0}
144+
> .input {$var :number minimumFractionDigits=0}
145145
> {{Redeclaration of a local variable}}
146146
>
147-
> .input {$var :number minFractionDigits=0}
148-
> .local $var = {$ext :number maxFractionDigits=0}
147+
> .input {$var :number minimumFractionDigits=0}
148+
> .local $var = {$ext :number maximumFractionDigits=0}
149149
> {{Redeclaration of an input variable}}
150150
>
151-
> .input {$var :number minFractionDigits=$var2}
151+
> .input {$var :number minimumFractionDigits=$var2}
152152
> .input {$var2 :number}
153153
> {{Redeclaration of the implicit input variable $var2}}
154154
>
@@ -284,16 +284,16 @@ An **_<dfn>Unsupported Statement</dfn>_** error occurs when a message includes a
284284
285285
> For example, attempting to format either of the following messages
286286
> might result in a _Selection Error_ if done within a context that
287-
> uses a `:plural` selector function which requires its input to be numeric:
287+
> uses a `:number` selector function which requires its input to be numeric:
288288
>
289289
> ```
290-
> .match {|horse| :plural}
290+
> .match {|horse| :number}
291291
> 1 {{The value is one.}}
292292
> * {{The value is not one.}}
293293
> ```
294294
>
295295
> ```
296-
> .local $sel = {|horse| :plural}
296+
> .local $sel = {|horse| :number}
297297
> .match {$sel}
298298
> 1 {{The value is one.}}
299299
> * {{The value is not one.}}
@@ -331,3 +331,4 @@ or an internally inconsistent set of options.
331331
> ```
332332
> Your {$field} is {$id :get field=$field}
333333
> ```
334+

spec/formatting.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,8 @@ foo bar {{Foo and bar}}
591591
592592
A more-complex example is the matching found in selection APIs
593593
such as ICU's `PluralFormat`.
594-
Suppose that this API is represented here by the function `:plural`.
595-
This `:plural` function can match a given numeric value to a specific number _literal_
594+
Suppose that this API is represented here by the function `:number`.
595+
This `:number` function can match a given numeric value to a specific number _literal_
596596
and **_also_** to a plural category (`zero`, `one`, `two`, `few`, `many`, `other`)
597597
according to locale rules defined in CLDR.
598598
@@ -601,7 +601,7 @@ and an `en` (English) locale,
601601
the pattern selection proceeds as follows for this message:
602602
603603
```
604-
.match {$count :plural}
604+
.match {$count :number}
605605
one {{Category match}}
606606
1 {{Exact match}}
607607
* {{Other match}}

spec/syntax.md

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ external input value does not appear in a previous _declaration_.
190190
> than one applied to the same _variable_ named in a _declaration_.
191191
> For example, this message is _valid_:
192192
> ```
193-
> .input {$var :number maxFractionDigits=0}
194-
> .match {$var :plural maxFractionDigits=2}
193+
> .input {$var :number maximumFractionDigits=0}
194+
> .match {$var :number maximumFractionDigits=2}
195195
> 0 {{The selector can apply a different annotation to {$var} for the purposes of selection}}
196-
> * {{A placeholder in a pattern can apply a different annotation to {$var :number maxFractionDigits=3}}}
196+
> * {{A placeholder in a pattern can apply a different annotation to {$var :number maximumFractionDigits=3}}}
197197
> ```
198198
> (See the [Errors](./errors.md) section for examples of invalid messages)
199199
@@ -356,8 +356,8 @@ match-statement = match 1*([s] selector)
356356
>
357357
> ```
358358
> .match {$count :number}
359-
> 1 {{You have one notification.}}
360-
> * {{You have {$count} notifications.}}
359+
> one {{You have {$count} notification.}}
360+
> * {{You have {$count} notifications.}}
361361
> ```
362362
363363
> A _message_ containing a _matcher_ formatted on a single line:
@@ -380,8 +380,9 @@ selector = expression
380380
There MUST be at least one _selector_ in a _matcher_.
381381
There MAY be any number of additional _selectors_.
382382

383-
> A _message_ with a single _selector_ that uses a custom `:hasCase` _function_,
384-
> allowing the _message_ to choose a _pattern_ based on grammatical case:
383+
> A _message_ with a single _selector_ that uses a custom _function_
384+
> `:hasCase` which is a _selector_ that allows the _message_ to choose a _pattern_
385+
> based on grammatical case:
385386
>
386387
> ```
387388
> .match {$userName :hasCase}
@@ -393,13 +394,16 @@ There MAY be any number of additional _selectors_.
393394
> A message with two _selectors_:
394395
>
395396
> ```
396-
> .match {$photoCount :number} {$userGender :equals}
397-
> 1 masculine {{{$userName} added a new photo to his album.}}
398-
> 1 feminine {{{$userName} added a new photo to her album.}}
399-
> 1 * {{{$userName} added a new photo to their album.}}
400-
> * masculine {{{$userName} added {$photoCount} photos to his album.}}
401-
> * feminine {{{$userName} added {$photoCount} photos to her album.}}
402-
> * * {{{$userName} added {$photoCount} photos to their album.}}
397+
> .match {$numLikes :number} {$numShares :number}
398+
> 0 0 {{Your item has no likes and has not been shared.}}
399+
> 0 one {{Your item has no likes and has been shared {$numShares} time.}}
400+
> 0 * {{Your item has no likes and has been shared {$numShares} times.}}
401+
> one 0 {{Your item has {$numLikes} like and has not been shared.}}
402+
> one one {{Your item has {$numLikes} like and has been shared {$numShares} time.}}
403+
> one * {{Your item has {$numLikes} like and has been shared {$numShares} times.}}
404+
> * 0 {{Your item has {$numLikes} likes and has not been shared.}}
405+
> * one {{Your item has {$numLikes} likes and has been shared {$numShares} time.}}
406+
> * * {{Your item has {$numLikes} likes and has been shared {$numShares} times.}}
403407
> ```
404408
405409
### Variant
@@ -531,7 +535,7 @@ function = ":" identifier *(s option)
531535
> A _message_ with a _function_ operating on the _variable_ `$now`:
532536
>
533537
> ```
534-
> It is now {$now :datetime}
538+
> It is now {$now :datetime}.
535539
> ```
536540
537541
##### Options
@@ -556,34 +560,18 @@ option = identifier [s] "=" [s] (literal / variable)
556560
557561
> Examples of _functions_ with _options_
558562
>
559-
> A _message_ with a `$date` _variable_ formatted with the `:datetime` _function_:
563+
> A _message_ using the `:datetime` function.
564+
> The _option_ `weekday` has the literal `long` as its value:
560565
>
561566
> ```
562-
> Today is {$date :datetime weekday=long}.
567+
> Today is {$date :datetime weekday=long}!
563568
> ```
564569
565-
> A _message_ with a `$userName` _variable_ formatted with
566-
> the custom `:person` _function_ capable of
567-
> declension (using either a fixed dictionary, algorithmic declension, ML, etc.):
570+
> A _message_ using the `:datetime` function.
571+
> The _option_ `weekday` has a variable `$dateStyle` as its value:
568572
>
569573
> ```
570-
> Hello, {$userName :person case=vocative}!
571-
> ```
572-
573-
> A _message_ with a `$userObj` _variable_ formatted with
574-
> the custom `:person` _function_ capable of
575-
> plucking the first name from the object representing a person:
576-
>
577-
> ```
578-
> Hello, {$userObj :person firstName=long}!
579-
> ```
580-
581-
> A _message_ formatted with the custom _function_ `:list`
582-
> that has an option `maxEntries`
583-
> that has a _variable_ as its value:
584-
>
585-
> ```
586-
> Hello, {$userList :list maxEntries=$maxEntries}!
574+
> Today is {$date :datetime weekday=$dateStyle}!
587575
> ```
588576
589577
#### Private-Use Annotations
@@ -828,9 +816,9 @@ Otherwise, the set of characters allowed in a _name_ is large.
828816
Examples:
829817
> A variable:
830818
>```
831-
>This has a {$variable}
819+
> This has a {$variable}
832820
>```
833-
>A function:
821+
> A function:
834822
> ```
835823
> This has a {:function}
836824
> ```

0 commit comments

Comments
 (0)