Skip to content

Commit 8d58f80

Browse files
aphillipseemeli
andauthored
Implement text-mode-first syntax (#500)
* Implement text-mode-first syntax Following the 2023-10-23 teleconference, implement "option 2a with additional ugliness". (This PR is not yet ready for review. It will include updating the syntax.md.) * Update syntax.md * Update formatting.md * Update README.md - includes the local / input change * Fix some minor formatting * Un-aligning rule `=` signs * Update spec/syntax.md Co-authored-by: Eemeli Aro <[email protected]> * Update registry.md * Update registry.md * Fix some message formatting * Missing example in The Message * Fix `pattern` ABNF and add `quoted-pattern` ABNF to syntax * Fix English for `quoted-pattern` * Fix text about quoting whitespace in `text` * Update spec/syntax.md Co-authored-by: Eemeli Aro <[email protected]> --------- Co-authored-by: Eemeli Aro <[email protected]>
1 parent 3daea5a commit 8d58f80

File tree

5 files changed

+215
-149
lines changed

5 files changed

+215
-149
lines changed

README.md

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,44 @@ The syntax is formally described in [ABNF](spec/message.abnf).
1717

1818
Messages can be simple strings:
1919

20-
{Hello, world!}
20+
Hello, world!
2121

2222
Messages can interpolate arguments formatted using _formatting functions_:
2323

24-
{Today is {$date :datetime weekday=long}.}
24+
Today is {$date :datetime weekday=long}.
2525

2626
Messages can define variants which correspond to the grammatical (or other) requirements of the language:
2727

28+
{{
2829
match {$count :number}
29-
when 1 {You have one notification.}
30-
when * {You have {$count} notifications.}
30+
when 1 {{You have one notification.}}
31+
when * {{You have {$count} notifications.}}
32+
}}
3133

3234
The message syntax is also capable of expressing more complex translation, for example:
3335

34-
let $hostName = {$host :person firstName=long}
35-
let $guestName = {$guest :person firstName=long}
36-
let $guestsOther = {$guestCount :number offset=1}
36+
{{
37+
local $hostName = {$host :person firstName=long}
38+
local $guestName = {$guest :person firstName=long}
39+
local $guestsOther = {$guestCount :number offset=1}
3740

3841
match {$host :gender} {$guestOther :number}
3942

40-
when female 0 {{$hostName} does not give a party.}
41-
when female 1 {{$hostName} invites {$guestName} to her party.}
42-
when female 2 {{$hostName} invites {$guestName} and one other person to her party.}
43-
when female * {{$hostName} invites {$guestName} and {$guestsOther} other people to her party.}
44-
45-
when male 0 {{$hostName} does not give a party.}
46-
when male 1 {{$hostName} invites {$guestName} to his party.}
47-
when male 2 {{$hostName} invites {$guestName} and one other person to his party.}
48-
when male * {{$hostName} invites {$guestName} and {$guestsOther} other people to his party.}
49-
50-
when * 0 {{$hostName} does not give a party.}
51-
when * 1 {{$hostName} invites {$guestName} to their party.}
52-
when * 2 {{$hostName} invites {$guestName} and one other person to their party.}
53-
when * * {{$hostName} invites {$guestName} and {$guestsOther} other people to their party.}
43+
when female 0 {{{$hostName} does not give a party.}}
44+
when female 1 {{{$hostName} invites {$guestName} to her party.}}
45+
when female 2 {{{$hostName} invites {$guestName} and one other person to her party.}}
46+
when female * {{{$hostName} invites {$guestName} and {$guestsOther} other people to her party.}}
47+
48+
when male 0 {{{$hostName} does not give a party.}}
49+
when male 1 {{{$hostName} invites {$guestName} to his party.}}
50+
when male 2 {{{$hostName} invites {$guestName} and one other person to his party.}}
51+
when male * {{{$hostName} invites {$guestName} and {$guestsOther} other people to his party.}}
52+
53+
when * 0 {{{$hostName} does not give a party.}}
54+
when * 1 {{{$hostName} invites {$guestName} to their party.}}
55+
when * 2 {{{$hostName} invites {$guestName} and one other person to their party.}}
56+
when * * {{{$hostName} invites {$guestName} and {$guestsOther} other people to their party.}}
57+
}}
5458

5559
See more examples and the formal definition of the grammar in [spec/syntax.md](./spec/syntax.md).
5660

0 commit comments

Comments
 (0)