Message
format

Playground

One call, and what it answers with. The parser runs in this page: nothing is sent anywhere, and the address bar carries the whole case, so a link reproduces it exactly.

  • {{ ; : }} Structure
  • key Payload entry
  • modifier Modifier
  • option Option key
  • \ Escape
  • \ Cancels nothing

The message as a host's translations hold it. An empty message is still a message, and resolves to the empty string — as does a call a host makes with no message at all, which has nothing to resolve.

What a locale-dependent modifier formats for. Switch it and the same message and payload come out as that locale writes them.

Modifier properties

What each modifier is configured with, by the name it is called under — the layer props carries. {"currency": {"currency": "EUR"}} says what currency the currency modifier formats in.

Output

Reports

Parameters

The colours

The message is coloured from the same parser that resolves it, by the tree CST.md specifies: one span per leaf, and the leaves tile the message. So the colouring cannot disagree with the parse — what is drawn as a placeholder is what resolution will read as one, and text the parser never found a placeholder in stays the colour of text. The two escapes are drawn apart on purpose: \{ cancels a brace and leaves one behind, while \n cancels nothing and both characters stay. An editor that colours them alike is lying about one of them.

Every message on this site is coloured by that same walk, so an example in the specification is drawn exactly as the message you type here would be. The payload and the modifier properties are JSON rather than messages, and are coloured as JSON — by their own reading, which is why a field mid-edit still colours rather than waiting for the text to parse.

Placeholders inside placeholders

A placeholder may hold a placeholder in an option value, and nowhere else. {{count:gt; 0:{{count:number;}}; default:no;}} is one placeholder holding another, read whole by one scan: the comparison selects among the options the message spelled, and the inner placeholder is resolved only where the option holding it is the one selected. At a count of 1234 the comparison selects the option that holds the inner placeholder, so it is resolved: number formats the count, and the locale above decides how the groups are separated. Drop the count to 0 and nothing is greater than zero, so the default is read and the inner placeholder is never resolved at all — no payload entry is read for it, no modifier runs, and no report it would have made is made. The colouring says as much: the whole construct is drawn as a placeholder, with the inner one inside its option value. Section 12 states the rule, section 13 the limits that bound it.

A {{ in a key, in an option key or in a modifier name opens nothing: the construct around it does not derive at all, and the scan resumes one brace along. And what a placeholder resolves to is nested in nothing — a payload value holding {{v}} renders those five characters, one holding ; ends no option, and one holding }} closes nothing. Type one in and watch the colouring stay where it is.

What you are running

@curly-message/parser 3.0.0, the reference implementation, served from this site and run in this browser. It is the build the version above names, not this page's own copy of the format.

Locale-dependent modifiers render through this browser's own internationalization data. number, date, currency and ago ask the host to format, and hosts differ: the same message, payload and locale can come out differently here, in another browser and in Node. What this page shows is what your browser makes of the message — a reading, not a canonical one. Everything else the format specifies is the parser's own and is the same everywhere.