Set the language
locale: in the app block sets the language of the text the engine draws around your
application: buttons, error pages, form messages, empty states, and the way numbers, money and
dates are written.
app my_club "My Club" { locale: en timezone: Europe/Berlin}Six values are accepted:
| Value | Language |
|---|---|
en |
English. This is the default when an application declares no locale: |
de |
German |
fr |
French |
es |
Spanish |
pt |
Portuguese, in its Brazilian spelling and wording |
tr |
Turkish |
Any other value is a compile error. The message names the six values the engine can draw.
The engine addresses the reader formally in every language: Sie in German, vous in French,
usted in Spanish, você in Portuguese and siz in Turkish. The Spanish is the neutral
international one, with words that read naturally in Spain and in Latin America. The Portuguese
is Brazilian (senha, arquivo, Entrar); a reader in Portugal understands it, and the
language pt-PT in an Accept-Language header selects it too.
Your own labels, help texts and messages are shown as you wrote them. An application can carry
translations of them (see Translate an app) and list the languages
with locales:.
Then each reader chooses one, as described in Let readers choose a language
below.
What the locale changes
Section titled “What the locale changes”en |
de |
fr |
es |
pt |
tr |
|
|---|---|---|---|---|---|---|
| a date | 2026-07-01 |
01.07.2026 |
01/07/2026 |
01/07/2026 |
01/07/2026 |
01.07.2026 |
| a time | 2026-07-01 15:30 |
01.07.2026, 15:30 |
01/07/2026 15:30 |
01/07/2026, 15:30 |
01/07/2026 15:30 |
01.07.2026 15:30 |
| a whole number | 1,234 |
1.234 |
1 234 |
1.234 |
1.234 |
1.234 |
| an amount of money | €1,234.50 |
1.234,50 € |
1 234,50 € |
1.234,50 € |
€ 1.234,50 |
€1.234,50 |
| an amount in a form field | 1234.50 |
1234,50 |
1234,50 |
1234,50 |
1234,50 |
1234,50 |
a decimal(1) |
1,234.5, and 1234.5 in a form field |
1.234,5, and 1234,5 in a form field |
1 234,5, and 1234,5 in a form field |
1.234,5, and 1234,5 in a form field |
1.234,5, and 1234,5 in a form field |
1.234,5, and 1234,5 in a form field |
| a CSV export | comma-separated, . before the cents |
semicolon-separated, , before the cents |
semicolon-separated, , before the cents |
semicolon-separated, , before the cents |
semicolon-separated, , before the cents |
semicolon-separated, , before the cents |
In French the digits are grouped by a narrow no-break space (U+202F), and a no-break space
(U+00A0) stands between the amount and the euro sign, so a number never breaks over two lines.
In Spanish a no-break space stands before the euro sign, and the digits of a number from four
digits up are grouped by a dot, as in German (the Spanish academy leaves a four-digit number
ungrouped; the engine groups it, so one rule serves every column). Rich text draws the
quotation marks of the language: “a” in English, „a“ in German, « a » in French (with
narrow no-break spaces inside), «a» in Spanish, and “a” in Portuguese and in Turkish.
In Portuguese the euro sign comes before the amount and a no-break space follows it (€ 1.234,50,
as Brazil writes R$ 1.234,50). In Turkish the euro sign comes before the amount with no gap
(€1.234,50). Both write a date and time with one space, so a spreadsheet reads a copied cell as a
point in time.
A date field accepts ISO dates (2026-07-01) and German dates (01.07.2026) in every locale.
A day-first date with slashes (01/07/2026) is accepted under fr, es and pt only: under en it
would be January 7th to a reader in the United States, so an English form refuses it instead of
choosing.
An amount field reads the locale’s own notation: under en, 1,234.50 is one thousand two
hundred and thirty-four euros fifty and 12,50 is refused; under de and es it is the other
way round, and pt and tr read like de. Under fr, the comma is the decimal separator and any space groups three digits, so
1 234,50 (with an ordinary, no-break or narrow no-break space) is one thousand two hundred and
thirty-four euros fifty, and 12 50, 12.50, 1.234 and 1,234.50 are refused. Under de,
es, pt and tr, a point over one or two digits is read as the decimal point (12.50 is twelve euros
fifty). The engine refuses an ambiguous amount instead of guessing a factor of a hundred. A
decimal field reads the same notation without the euro sign.
Turkish letters in search and sort
Section titled “Turkish letters in search and sort”Search and sort use one rule for every language: a search folds case with Unicode simple lowercase, and a sort follows the German alphabet. Turkish has a dotted and a dotless i, and these rules do not know the pair. In a Turkish application:
İstanbul,ISTANBULandistanbulfind each other, becauseİandIboth fold toi.ISPARTAis found byispartaand not byısparta, which is its Turkish lower case.ığdıris found byığdırand not byIĞDIR, because the capitalIfolds to a dottedi.- A sort puts the dotless
ıafter every word that has ani, where a Turkish reader expects it before.
Nothing is refused or changed: every letter is stored, shown and exported as it was typed.
The locale: changes no stored value. Money is always stored in cents and a date always as an
ISO date.
Let readers choose a language
Section titled “Let readers choose a language”An application that lists more than one language in locales: lets each reader choose. An
application with one language does none of this: no selector is drawn, no header is read, and
the pages are exactly what they were.
app school "Sampletown Grammar School" { locale: en locales: [en, de]}For every request the engine takes the first of these that names a listed language:
- The account. A signed-in reader who chose a language has it stored on their login.
- The cookie. The selector sets the cookie
__Host-mtd_lang. It is HttpOnly andSameSite=Lax, and it lasts one year. A value that is not one of the listed languages is ignored. Accept-Language. The engine reads the weights (q=), refuses a language withq=0, and matches a regional tag by its first part, sode-ATselectsde. It reads at most the first 1,024 bytes and the first 32 entries of the header. A language the application does not list, and*, are ignored.locale:, the default.
Each of these is checked against the list. A cookie or a header that names another language is not an error: the engine goes on to the next source.
The selector
Section titled “The selector”Every page of such an application, except a bare page such as the login, shows a small form in
the header row: a list of the languages, each named in its own language (Deutsch, English),
and a Change button. On the login page it is in the footer. The form is a POST to
/matterdata/language with the same CSRF token as every other form, so it works with
JavaScript switched off. It sets the cookie, stores the choice on the account of a signed-in
reader, and returns to the page it was sent from. A value that is not a listed language is
refused with a 400 and sets nothing. On a public page
the control is a list of links instead of a form.
A form keeps the language it was drawn in
Section titled “A form keeps the language it was drawn in”A form is drawn in one language. If the reader switches to another in a second tab, 12,50
in the first form still means twelve euros fifty. So every form, sheet and grid of such an
application carries the language it was drawn in, and the save is read in that language. A
refused form is drawn again in the same language, with what the person typed. A form that names
a language the page does not offer is refused with a 400.
Headers
Section titled “Headers”A page of such an application answers with Vary: Accept-Language, Cookie and
Content-Language, and the lang attribute of <html> is the language it was drawn in. The
stylesheet, the scripts and pictures send neither. A public page at a prefixed address answers
with Vary: Cookie only, because its language does not depend on a header.
Public pages have one address for each language
Section titled “Public pages have one address for each language”A search engine sends no Accept-Language header and no cookie. It indexes addresses. So a
public page of an application that lists several languages has one
address for each language, and the language is in the address:
| Address | Language |
|---|---|
/blog/post |
the application’s own language (locale:). It is never prefixed |
/de/blog/post |
German |
/de/club/post |
German, when the application is mounted at club |
The default language stays at the address it always had, so adding a language later breaks no existing address or link. The prefix is the same for the whole organization and comes before the mount. Every language the engine can draw is reserved as a first segment, whether or not the application lists it (see Language codes).
The rules, in the order the engine applies them:
- The prefix decides the language. The engine does not read the cookie, the account or
Accept-Languagefor a prefixed address. Two readers with different browsers see the same page at the same address. - The default’s own prefix is a duplicate.
/en/blog/postanswers301with the address/blog/post, when English is the application’s language. In an organization with several applications, “default” is the language of that application. - A language the application does not list is a 404.
/de/blog/postis a 404 for an application that lists only English. - Only a public page has a prefixed address. A page that is not public (a page with a
role, or a
publicrule with awhere:) has one address. AGETof it under a prefix answers301with the address without the prefix, for every reader, signed in or not. APOSTto it under a prefix is a 404. The engine’s own pages (/matterdata/…) work the same way. A menu on a prefixed page links a page that is not public without the prefix. - An unprefixed first visit is sent to its language, once. When a
GETof a public page at the unprefixed address has no cookie or account choice, andAccept-Languagenames another listed language, the engine answers302with the prefixed address andVary: Accept-Language, Cookie. A request with no header, such as a crawler, gets the default language at the unprefixed address. A request that comes from a link on the same site (the browser sendsSec-Fetch-Site: same-origin, or aRefererwith the same host) is never sent back. So a click on the link for the default language shows the default language. The engine never redirects aPOST.
Each public page of such an application carries in its <head>:
<link rel="canonical" href="https://club.example/de/blog/post"><link rel="alternate" hreflang="en" href="https://club.example/blog/post"><link rel="alternate" hreflang="de" href="https://club.example/de/blog/post"><link rel="alternate" hreflang="x-default" href="https://club.example/blog/post">The addresses are absolute and use the host the reader reached. x-default is the unprefixed
address. The page answers with Content-Language, and <html lang> is its language. On a
paginated list the page number (?page=2) is part of each address.
The language control of a public page is a list of plain links to the same page in each
language. Each link has lang and hreflang, and the current language has
aria-current="true". Following a link stores nothing: the address is the choice. Pages that
are not public keep the selector described above.
Forms on a prefixed page
Section titled “Forms on a prefixed page”A form on /de/contact posts to /de/contact, and the amounts in it are read in German
notation. Its address and its hidden mtd_locale field must name the same language. If they
differ, the engine answers 400 and saves nothing. The redirect after a save, the return
address of a form (mtd_return) and the links a list draws keep the prefix. A mtd_return
that names a prefixed address of a page that is not public, or the default language’s prefix,
is ignored.
The address of an image, and the scope selector of an application, do not carry a prefix. They are one address for every language.
Pages that belong to no application
Section titled “Pages that belong to no application”The login page, the application chooser and the administration pages under /matterdata belong
to the organization, not to one application. They follow the reader’s language too. In an
organization with several applications, the choices are English and every language any of its
applications lists. When no source names a language, the page uses the locale: that all the
applications of the organization share, and English when they differ. The application names and the role labels on these pages are drawn in that
language, or in the application’s own language when it does not list it. When the organization
has one application, these pages offer the languages of that application.
Translate what a hook says
Section titled “Translate what a hook says”A before hook refuses a write with throw ctx.error(…). To translate the sentence, declare it in
the app block and refer to it by its name:
messages { basket_in_use "This basket is in use by {:name}."}throw ctx.error("basket_in_use", { name: basket.name });Then translate it like any other text. The key is message.<name>:
i18n de { message.basket_in_use "Dieser Korb wird von {:name} benutzt." was "This basket is in use by {:name}."}The engine draws the sentence in the language of the request, or in the language the form was
drawn in (see A form keeps the language it was drawn in).
A value from the hook is drawn as text, so <b> in it is shown as the characters. A refusal is
drawn in the page that was answered and is not stored, so a change of language cannot leave a
sentence in the wrong language. A hook that refuses with a sentence instead of a name still
works, and the sentence is shown as written in every language. In an application that lists more
than one language, the compiler warns about it, and matterdata validate -strict refuses it. The rules and the compile-time checks are under
messages.
What is not translated
Section titled “What is not translated”- The text inside an expression, such as
"open"instatus = "open". Give the word to anenumvalue and translate that. - Text that goes to someone other than the reader on screen: the invitation mail, the text of a
scheduled job and the text a hook sends with
SendMail. It is drawn in the language of the sender or of the application, and not in the language of the recipient.