Skip to content

Commit a5eb9a3

Browse files
catamorphismeemeli
andauthored
Clarification to default bidi strategy (#968)
* Add note elaborating on what the directionality of the resolved value means * Avoid breaking up algorithm steps with NOTE * Incorporate feedback from Eemeli * Avoid repetition * Rewrite to not define an auxiliary function * Incorporate feedback from Eemeli * Add directionality methods to MessageValue * Update spec/formatting.md Co-authored-by: Eemeli Aro <[email protected]> * Update spec/formatting.md Co-authored-by: Eemeli Aro <[email protected]> --------- Co-authored-by: Eemeli Aro <[email protected]>
1 parent 05aea1b commit a5eb9a3

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

spec/formatting.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ identifies not only the name of the external input value,
131131
but also the _variable_ to which the _resolved value_ of the _variable-expression_ is bound.
132132
133133
In a _pattern_, the _resolved value_ of an _expression_ or _markup_ is used in its _formatting_.
134+
To support the _Default Bidi Strategy_,
135+
the _resolved value_ of each _expression_
136+
SHOULD include information about the directionality
137+
of its formatted string representation,
138+
as well as a flag to indicate whether
139+
its formatted representation requires isolation
140+
from the surrounding text.
134141
135142
The form that _resolved values_ take is implementation-dependent,
136143
and different implementations MAY choose to perform different levels of resolution.
@@ -146,6 +153,8 @@ and different implementations MAY choose to perform different levels of resoluti
146153
> getValue(): unknown
147154
> resolvedOptions(): { [key: string]: MessageValue }
148155
> selectKeys(keys: string[]): string[]
156+
> directionality(): 'LTR' | 'RTL' | 'unknown'
157+
> isolate(): boolean
149158
> }
150159
> ```
151160
>
@@ -940,11 +949,12 @@ The _Default Bidi Strategy_ is defined as follows:
940949
Note that this is normally the empty string.
941950
1. Append `fmt` to `out`.
942951
1. Else:
943-
1. Let `fmt` be the formatted string representation of the _resolved value_ of `part`.
944-
1. Let `dir` be the directionality of `fmt`,
952+
1. Let `resval` be the _resolved value_ of `part`.
953+
1. Let `fmt` be the formatted string representation of `resval`.
954+
1. Let `dir` be the directionality of `resval`,
945955
one of « `'LTR'`, `'RTL'`, `'unknown'` », with the same meanings as for `msgdir`.
946956
1. Let the boolean value `isolate` be
947-
True if the `u:dir` _option_ of the _resolved value_ of `part` has a value other than `'inherit'`,
957+
True if the `u:dir` _option_ of `resval` has a value other than `'inherit'`,
948958
or False otherwise.
949959
1. If `dir` is `'LTR'`:
950960
1. If `msgdir` is `'LTR'` and `isolate` is False:
@@ -963,4 +973,24 @@ The _Default Bidi Strategy_ is defined as follows:
963973
1. Append U+2069 POP DIRECTIONAL ISOLATE to `out`.
964974
1. Emit `out` as the formatted output of the message.
965975
976+
> [!NOTE]
977+
> As mentioned in the "Resolved Values" section,
978+
> the representation of a _resolved value_
979+
> can track everything needed
980+
> to determine the directionality
981+
> of the formatted string representation
982+
> of a _resolved value_.
983+
> Each _function handler_ can have its own means
984+
> for determining the directionality annotation
985+
> on the _resolved value_ it returns.
986+
> Alternately, an implementation could simply
987+
> determine directionality
988+
> based on the locale.
989+
990+
> [!IMPORTANT]
991+
> Directionality SHOULD NOT be determined by introspecting
992+
> the character sequence in the formatted string representation
993+
> of `resval`.
994+
995+
966996

0 commit comments

Comments
 (0)