Media and drawing
Languages and formats
Media and drawing
words.md

Languages and formats

An app in more than one language: its own strings in each (words), said with t("key", {…}) and checked by the compiler against the keys; numbers, money, shares, lists and counts in the language's own way (fmt); and the reader's language (screen.lang). Dates and times are time.* (data.md). Back to the map.

Examplea whole program
app "Shop"
words "en"
hello = "Hello, {name}!"
cart.items = {zero: "Your cart is empty", one: "{n} item in your cart", other: "{n} items in your cart"}
total = "Total: {sum}"
words "de"
hello = "Hallo, {name}!"
cart.items = {zero: "Dein Warenkorb ist leer", one: "{n} Artikel im Warenkorb", other: "{n} Artikel im Warenkorb"}
total = "Summe: {sum}"
state count = 0
column gap=8 padding=16
text t("hello", {name: "Ada"})
text t("cart.items", {n: count})
text t("total", {sum: fmt.currency(1234.5, "EUR")})
row gap=8
button "Add" press={count += 1}
button "Deutsch" press={words.choose("de")}
button "English" press={words.choose("en")}
text `Shown in ${words.lang}; you read ${screen.lang}`

Mental model#

The forms#

fmt#

Pitfalls#

In the source#

esc
1072 sections of 111 pages, ranked as you type.A heading's words count for more than what stands under it.
↑↓move
↵open
ranked by BM25, in the page