{"version":"v1.0","client_state":{"DocsNavigation.default":{"fields":{"query":""},"persist":"memory","send_to_server":true},"ColorScheme.default":{"fields":{"mode":"system"},"persist":"local","send_to_server":true}},"endpoints":{"action":"/_bretzel/action","sse":"/_bretzel/sse","refetch":"/_bretzel/refetch"},"csrf":"a3703b46e137da252608f9f81731e37e","page_id":"0f9ba539b3f14e0886a46e27793b802b","address":""}

Speaking the visitor's language

Declare the languages once. The framework's own sentences follow them; yours go through `t()`, with a table per language.

What the framework does on its own

The sentences Bretzel produces — a carousel's accessibility labels, a `file_upload`'s maximum-size message, a table's result count — ship in English and French, and follow the language. Dates and numbers are shown the language's way: a date field reads `16/10/2026` in French and `10/16/2026` in American English, a number field `2,5` and `2.5` — the value posted stays the same.
app = Bretzel(
    secret_key="…",
    lang="en",                  # the default language
    languages=("en", "fr"),     # the ones we accept
)
The language is resolved PER REQUEST: an explicit choice wins over the browser's header, and a language one has not declared falls back to the default. A single sentence of the framework can still be replaced, in the same `translations=` table, by its name (`"sidebar.toggle"`).

Your app's sentences: t()

Write the sentence in the code, in the app's language, and give the others in a table. The sentence is the key: the code reads like the screen, and a sentence nobody translated yet still shows, as written.
from bretzel import Bretzel, t, ui

app = Bretzel(
    lang="en", languages=("en", "fr"),
    translations={"fr": {
        "Save": "Enregistrer",
        "Hello {name}": "Bonjour {name}",
    }},
)

ui.button(t("Save"), color="primary")
ui.text(t("Hello {name}", name=user.name))
`t()` reads the request's language, so it is called while rendering or handling — never in a module-level constant, evaluated once for nobody. A translated list is a function, not a tuple.

Counting

A sentence with a number has several forms, and each language picks its own: English says the singular for 1 only, French for 0 and 1, Russian or Polish have a third and a fourth form. Give the plural in the code, the forms in the table — the language's rule chooses.
ui.text(t("{n} task", n=count, plural="{n} tasks"))

# in translations={"fr": {...}}:
"{n} task": {"one": "{n} tâche", "other": "{n} tâches"},

What a table still lacks

The command reads the app's code for every `t("…")` and prints, language by language, the sentences a table lacks — with where they are called — and the entries no call uses any more. At startup, a table for an undeclared language or a renamed hole raises.
bretzel translations main:app

Letting the user choose

`Language.set` is a SERVER handler: it picks the language and reloads the page in it. So one passes it as a `partial`, not as a call — `Language.set("fr")` would run at RENDER time, not on the click.
from functools import partial

ui.button("English", on_click=partial(Language.set, "en"))
ui.button("Français", on_click=partial(Language.set, "fr"))
Why this exists when the language is already automatic: `Accept-Language` describes the operating system's configuration, not a reading choice. With no way of saying otherwise, somebody whose machine is in English cannot read in French.

What it does not do

The limits
The tables are Python dicts, not `.po` files: an app that hands them to translators loads them from the files it prefers. Dates and numbers written by the server — in a sentence, a cell — are formatted by the app; the framework formats those of its fields, in the browser. Right-to-left languages are not handled.