@@ -7,10 +7,19 @@ when formatting a message for display in a user interface, or for some later pro
77
88To start, we presume that a _ message_ has either been parsed from its syntax
99or created from a data model description.
10- If this construction has encountered any _ Syntax Errors _ or _ Data Model Errors _ ,
11- an appropriate error MUST be emitted and a _ fallback value _ MAY be used as the formatting result .
10+ If the resulting _ message _ is not _ well-formed _ , a _ Syntax Error _ is emitted.
11+ If the resulting _ message _ is _ well-formed _ but is not _ valid _ , a _ Data Model Error _ is emitted .
1212
13- Formatting of a _ message_ is defined by the following operations:
13+ The formatting of a _ message_ is defined by the following operations:
14+
15+ - ** _ <dfn >Pattern Selection</dfn >_ ** determines which of a message's _ patterns_ is formatted.
16+ For a message with no _ selectors_ , this is simple as there is only one _ pattern_ .
17+ With _ selectors_ , this will depend on their resolution.
18+
19+ - ** _ <dfn >Formatting</dfn >_ ** takes the resolved values of the selected _ pattern_ ,
20+ and produces the formatted result for the _ message_ .
21+ Depending on the implementation, this result could be a single concatenated string,
22+ an array of objects, an attributed string, or some other locally appropriate data type.
1423
1524- ** _ <dfn >Expression and Markup Resolution</dfn >_ ** determines the value of an _ expression_ or _ markup_ ,
1625 with reference to the current _ formatting context_ .
@@ -24,6 +33,15 @@ Formatting of a _message_ is defined by the following operations:
2433 The resolution of _ text_ is rather straightforward,
2534 and is detailed under _ literal resolution_ .
2635
36+ Implementations are not required to expose
37+ the _ expression resolution_ and _ pattern selection_ operations to their users,
38+ or even use them in their internal processing,
39+ as long as the final _ formatting_ result is made available to users
40+ and the observable behavior of the _ formatting_ matches that described here.
41+
42+ _ Attributes_ MUST NOT have any effect on the formatted output of a _ message_ ,
43+ nor be made available to function implementations.
44+
2745> [ !IMPORTANT]
2846>
2947> ** This specification does not require either eager or lazy _ expression resolution_ of _ message_
@@ -39,27 +57,6 @@ Formatting of a _message_ is defined by the following operations:
3957> have already been evaluated in the order in which the relevant _ declarations_
4058> and _ selectors_ appear in the _ message_ .
4159
42- - ** _ <dfn >Pattern Selection</dfn >_ ** determines which of a message's _ patterns_ is formatted.
43- For a message with no _ selectors_ , this is simple as there is only one _ pattern_ .
44- With _ selectors_ , this will depend on their resolution.
45-
46- At the start of _ pattern selection_ ,
47- if the _ message_ contains any _ reserved statements_ ,
48- emit an _ Unsupported Statement_ error.
49-
50- - ** _ <dfn >Formatting</dfn >_ ** takes the resolved values of the selected _ pattern_ ,
51- and produces the formatted result for the _ message_ .
52- Depending on the implementation, this result could be a single concatenated string,
53- an array of objects, an attributed string, or some other locally appropriate data type.
54-
55- Formatter implementations are not required to expose
56- the _ expression resolution_ and _ pattern selection_ operations to their users,
57- or even use them in their internal processing,
58- as long as the final _ formatting_ result is made available to users
59- and the observable behavior of the formatter matches that described here.
60-
61- _ Attributes_ MUST NOT affect the processing or output of a _ message_ .
62-
6360## Formatting Context
6461
6562A message's ** _ <dfn >formatting context</dfn >_ ** represents the data and procedures that are required
@@ -82,8 +79,7 @@ At a minimum, it includes:
8279- The _ function registry_ ,
8380 providing the implementations of the functions referred to by message _ functions_ .
8481
85- - Optionally, a fallback string to use for the message
86- if it contains any _ Syntax Errors_ or _ Data Model Errors_ .
82+ - Optionally, a fallback string to use for the message if it is not _ valid_ .
8783
8884Implementations MAY include additional fields in their _ formatting context_ .
8985
@@ -192,8 +188,8 @@ If a _declaration_ exists for the _variable_, its resolved value is used.
192188Otherwise, the _variable_ is an implicit reference to an input value,
193189and its value is looked up from the _formatting context_ _input mapping_.
194190
195- The resolution of a _variable_ MAY fail if no value is identified for its _name_.
196- If this happens, an _Unresolved Variable_ error MUST be emitted.
191+ The resolution of a _variable_ fails if no value is identified for its _name_.
192+ If this happens, an _Unresolved Variable_ error is emitted.
197193If a _variable_ would resolve to a _fallback value_,
198194this MUST also be considered a failure.
199195
@@ -435,6 +431,17 @@ _Pattern selection_ is not supported for _fallback values_.
435431
436432## Pattern Selection
437433
434+ If the _message_ contains any _reserved statements_,
435+ emit an _Unsupported Statement_ error.
436+
437+ If the _message_ being formatted is not _well-formed_ and _valid_,
438+ the result of pattern selection is a _pattern_ consisting of a single _fallback value_
439+ using the _message_'s fallback string defined in the _formatting context_
440+ or if this is not available or empty, the U+FFFD REPLACEMENT CHARACTER `�`.
441+
442+ If the _message_ being formatted does not contain a _matcher_,
443+ the result of pattern selection is its _pattern_ value.
444+
438445When a _message_ contains a _matcher_ with one or more _selectors_,
439446the implementation needs to determine which _variant_ will be used
440447to provide the _pattern_ for the formatting operation.
@@ -504,11 +511,6 @@ This selection method is defined in more detail below.
504511An implementation MAY use any pattern selection method,
505512as long as its observable behavior matches the results of the method defined here.
506513
507- If the message being formatted has any _Syntax Errors_ or _Data Model Errors_,
508- the result of pattern selection MUST be a pattern resolving to a single _fallback value_
509- using the message's fallback string defined in the _formatting context_
510- or if this is not available or empty, the U+FFFD REPLACEMENT CHARACTER `�`.
511-
512514### Resolve Selectors
513515
514516First, resolve the values of each _selector_:
@@ -741,8 +743,8 @@ each _text_ and _placeholder_ part of the selected _pattern_ is resolved and for
741743
742744Resolved values cannot always be formatted by a given implementation.
743745When such an error occurs during _formatting_,
744- an implementation MUST emit an appropriate _Message Function Error_ and use a
745- _fallback value_ for the _placeholder_ with the error.
746+ an appropriate _Message Function Error_ is emitted and
747+ a _fallback value_ is used for the _placeholder_ with the error.
746748
747749Implementations MAY represent the result of _formatting_ using the most
748750appropriate data type or structure. Some examples of these include:
@@ -787,8 +789,9 @@ the _fallback value_ as a string,
787789and a U+007D RIGHT CURLY BRACKET `}`.
788790
789791> For example,
790- > a message with a _Syntax Error_ and no fallback string
791- > defined in the _formatting context_ would format to a string as `{�}`.
792+ > a _message_ that is not _well-formed_ would format to a string as `{�}`,
793+ > unless a fallback string is defined in the _formatting context_,
794+ > in which case that string would be used instead.
792795
793796### Handling Bidirectional Text
794797
0 commit comments