Log inGet started

The player's language

Updated December 5, 2026

Your world's text in the player's language

Write every word a player reads into a catalog, one JSON file per namespace and language, and read it with i18n.t. A world's catalogs live under /zero/source/locales/<tag>/<namespace>.json; en is the source and every other language is a translation of it:

// /zero/source/locales/en/hud.json
{
  "title": "Treasure Run",
  "score": "Score: {{ points }}",
  "gems_one": "{{ count }} gem left",
  "gems_other": "{{ count }} gems left",
  "pause": { "resume": "Resume", "quit": "Quit" }
}
// /zero/source/locales/pt-BR/hud.json
{
  "title": "Corrida do Tesouro",
  "score": "Pontos: {{ points }}",
  "gems_one": "Falta {{ count }} joia",
  "gems_other": "Faltam {{ count }} joias",
  "pause": { "resume": "Continuar", "quit": "Sair" }
}
i18n.t("hud.score", { points = 1250 })   -- "Score: 1,250"   ("Pontos: 1.250" for pt-BR)
i18n.t("hud.gems", { count = 1 })        -- "1 gem left"
i18n.t("hud.pause.resume")               -- "Resume"
  • A key is <namespace>.<key>: hud.pause.resume is pause.resume in hud.json. Every part is lowercase letters, digits and _, starting with a letter, and any such word is a part (move, type, final). A catalog file holding one part outside that (questCard, 1) is refused as a whole, so none of its keys reads from it: the write that saves it answers a catalog-refused diagnostic naming the key and what is wrong with it, and i18n.explain and i18n.check name it too.
  • {{ name }} is filled from the values you pass. A whole number is written the way the message's language writes it (1,250, 1.250); text is written as given. A number that names rather than counts (a year, an id, a level number shown as a label) goes in as text, tostring(2026), or it is grouped like a count (2,026). Format a fraction yourself and pass it as text.
  • A plural is one key per form the language uses, and only those: English has _one and _other; Brazilian Portuguese has _one, _many (exact millions) and _other, and reads 0 as _one ("0 moeda"). Pass count and the language's own rules pick the form. A sentence of its own for none ("No coins yet") is a separate key your code chooses when the count is 0. Never write n == 1 and "" or "s".
  • A key missing from the player's language is read from the next language of its fallback chain, then English. A key no catalog holds shows as the key itself, and the log says so once.

Which of your catalog languages a player gets is decided for each player from their own language list (their choice, ZeroMind's language, their device), matched against the locales/ folders your world has, then English: i18n.textLocale() answers it from your code. That is apart from the engine's own interface language, i18n.locale(), which is one of the locales the engine offers (i18n.offered(): en and pt-BR). A world's catalog languages reach a player whether or not the engine offers them: a world's German reaches a German player while the engine's own screens read English.

Text that follows the language on screen

i18n.text(key, values) is the same text as a value. Hand it to a widget wherever it takes text and the screen redraws in the new language when the player changes it, with no code of yours running:

ui.registerScreen("hud", {
    type = "vertical",
    children = {
        { type = "label", props = { text = i18n.text("hud.title") } },
        { type = "button", props = { text = i18n.text("hud.pause.resume"), onClick = "resume" } },
    },
})

text, title, header, placeholder, tooltip and a dropdown's options all take it, and every edui widget takes it as its label. A value inside values may be one too, or a function the text calls each time it renders, which is how a date or a count written in the player's language follows a language change as well:

local lastPlayed = { year = 2026, month = 3, day = 5 }
local line = i18n.text("hud.last_played", {
    date = function() return i18n.formatDate(lastPlayed) end,
})
-- "Last played on March 5, 2026", and "Última partida em 5 de março de 2026"
-- the moment the player's language turns Portuguese

tostring(value) renders it now.

Where the words come from

Code reads the catalogs of the place it lives in, layer by layer, for each language of the chain:

  1. the world's own: /zero/source/locales/
  2. the package the calling code belongs to: <name>.package/locales/
  3. the built-in library's

So a world can change any word a package or the library shows by stating the same key in its own catalog. When a screen shows a key, English inside a translated screen, or the wrong wording, ask where it came from:

local e = i18n.explain("hud.score")
-- { found = true, text = "Score: {{ points }}", locale = "en",
--   path = "/zero/source/locales/en/hud.json", searched = { ... every file tried, in order } }

A key whose file was refused answers found = false, and refused names each refused file among those searched, with the key it is refused at and what is wrong there:

i18n.explain("hud.score").refused
-- { { path = "/zero/source/locales/en/hud.json",
--     reason = "pause.questCard: the key segment `questCard` holds the uppercase letter `C`; ..." } }

Checking your catalogs

local r = i18n.check()          -- every catalog under /zero/source/locales
for _, e in r.errors do print(e) end

i18n.check runs the checks origozero.ai runs: each file parses, a translation holds only keys English holds, its placeholders and plural forms match the language, and each translated message has a review record.

The review record of a translation lives beside it, one per key:

// /zero/source/locales/pt-BR/hud.review.json
{
  "score": { "state": "draft", "source_sha": "5c1d0e7a9b2f4c61", "text_sha": "a07e3b9c1d2e4f58" }
}

state is draft (written, not reviewed yet), ai_reviewed (reviewed by someone other than its translator) or flagged. The two hashes pin the English and the translation the state was set against; you never compute them: a key without a record is reported with the record to write, hashes included, and a record whose English or translation changed since is reported stale.

A translated language's product terms live in /zero/source/glossary/<tag>.json, and the check holds every translation to them (the English says coin, the translation must say moeda):

// /zero/source/glossary/pt-BR.json
{
  "terms": [ { "source": ["coin", "coins"], "target": ["moeda*"], "note": "the collectible" } ],
  "exceptions": [],
  "same_as_english": []
}

A * ends a word prefix (moeda* is moeda and moedas). A translated language with no glossary is reported as a warning.

To see which text on a screen did not come from a catalog, show the pseudo-locale:

i18n.pseudo(true)    -- every catalog string reads ⟦Šçöŕé: 1,250⟧; plain English left is a literal
i18n.pseudo(false)

Numbers, sizes, dates and times

Each helper writes in the language your text is shown in (i18n.textLocale(): for a world's code, the one of its catalog languages the player reads), so a date reads in the language of the sentence around it; pass a locale tag last to write in another. Hand the result to a message as text:

i18n.t("hud.last_played", { date = i18n.formatDate(os.date("*t")) })
-- "Last played on October 20, 2026" / "Última partida em 20 de outubro de 2026"
i18n.formatNumber(1234567)                      -- "1,234,567"  / "1.234.567"
i18n.formatCompact(1200)                        -- "1.2K"       / "1,2 mil"
i18n.formatBytes(16200)                         -- "16.2 KB"    / "16,2 KB"
i18n.formatDate(os.date("*t"), "long")          -- "October 20, 2026" / "20 de outubro de 2026"
i18n.formatAgo(300)                             -- "5m ago"     / "há 5 min."
i18n.formatMoney(1250, "BRL")                   -- "R$12.50"    / "R$ 12,50"
i18n.plural(3)                                  -- "other"
i18n.upper("conexão")                           -- "CONEXÃO" (string.upper changes ASCII only)

Choosing among your own languages

When content holds its text some other way, say which languages it has text for, fallback first, and ask which one this player reads:

local GREETING = { en = "Welcome!", pt = "Bem-vindo!", es = "¡Bienvenido!" }

local function refresh()
    label.text = GREETING[i18n.pick({ "en", "pt", "es" })]
end
refresh()
i18n.onChange(refresh)   -- the player changed their language while playing

i18n.pick runs the engine's chain (below) over your list: a Brazilian player (pt-BR, then en) gets pt, a player on es-419 gets es, and a player whose languages your list does not hold gets the first entry. It answers one of your tags exactly as you wrote it.

To see the world as a visitor with another language list would, stand that list in, and put this machine's own back when done:

i18n.emulate({ "pt-BR", "en" })   -- i18n.preferred, pick, locale and onChange all follow
i18n.emulate(nil)                 -- this machine's own languages again

The player's own choice (i18n.choose, below) comes before the platform list in the chain, so an emulated list decides only while no choice is set; clear one with i18n.choose(nil).

The rest of the surface

i18n.preferred()    -- what the platform says the player reads, most preferred first
i18n.locale()       -- the locale the engine's own text is in: "en", "pt-BR", ...
i18n.offered()      -- the locales the engine offers for its own text, { tag, name, nativeName, fallback }
i18n.choice()       -- the player's own choice, or nil
i18n.sources()      -- every link of the chain and which one decided:
                    -- { locale, decidedBy, matched, choice?, zeromind?, platform, signedIn, choiceKept }

What the platform says the player reads

i18n.preferred() is the platform's own list, as BCP 47 tags in its canonical case (pt-BR, zh-Hant-TW), most preferred first:

platformread froma change reaches the engine
LinuxLANGUAGE, LC_ALL, LC_MESSAGES, LANG (a POSIX name such as pt_BR.UTF-8 reads as pt-BR; C and POSIX name no language)at boot
Windows, macOSthe user's language list in the OS settingsat boot, and each time the engine's window regains focus
browsernavigator.languageson the page's languagechange event
Androidthe activity's configuration locales: the app's own language when the player set one for it, the device's language list otherwiseon the configuration change, while the app keeps running

The list is what the platform reports and nothing more: a world that wants the player's region or second language reads it here.

How the locale is chosen

i18n.locale() and i18n.pick come from one chain. Each link is matched against the offered locales, and the first link that matches decides:

  1. The player's choice, set with i18n.choose(tag) and kept on the device for their ZeroMind account (the signed-out player has a choice of their own). It wins on every later boot.
  2. The language ZeroMind shows the player: their account's language, or the page's. ZeroMind's page passes it to the browser engine as the zeromindLocale boot argument; a desktop launch passes --zeromind-locale <tag>. An engine booted without it skips the link. When the reader picks another language on the page while the browser engine runs, the page tells the engine, which negotiates again from the new language, and i18n.onChange subscribers run once it has.
  3. The platform's preferred languages, in order.
  4. en, the engine's source language. i18n.pick takes your list's first entry here instead, so the fallback your content names is the one it gets.

A link matches an offered locale with the same tag, then one its tag truncates to (pt-BR-x-abc to pt-BR, de-CH to de), then the first offered locale of the same language (pt to pt-BR).

The engine offers a locale once its manifest is launched. Each manifest states the locale's tag, its name in English and in itself, its fallback chain (the locales a string missing from it is looked up in, en last) and whether it is launched. The engine offers en and pt-BR. A player none of whose links matches either gets en, and i18n.sources().decidedBy reads default.

local s = i18n.sources()
-- { locale = "pt-BR", decidedBy = "platform", matched = "pt-BR",
--   choice = nil, zeromind = nil, platform = { "pt-BR", "en-US" }, signedIn = true,
--   choiceKept = "device" }

Choosing

i18n.choose("pt-BR")             -- { ok = true, locale = "pt-BR", decidedBy = "choice" }
local refused = i18n.choose("de")
if not refused.ok then
    log.warn(refused.reason)     -- "`de` is not a locale the engine offers; it offers en, pt-BR"
end
i18n.choose(nil)                 -- clear the choice; the chain decides again

A person makes the same choice with no code: the Language group of the client settings (clientSettings, the setting language.locale) lists Follow my device and every offered locale by its own name, and says which language is in force and why. A player reaches it in the app menu's System tab (the pause menu, and the menu over the world chooser); the editor reaches it from its Zero menu (Settings…) and its Settings menu (Language). Picking one there is i18n.choose(tag), and Follow my device is i18n.choose(nil). language_menu.choices() lists the same choices (require("@builtin::modules.api.engine.language_menu")).

Only an offered locale can be chosen. The choice is kept for the account the engine is signed in as and comes back on the next boot on this device:

platformwhere
Linux, Windows, macOS<data root>/account_prefs/, one JSON file per account (the data root the engine's other saved data lives under; ZERO_DATA_DIR overrides it)
Androidaccount_prefs/ in the app's files directory
browserIndexedDB database zero-account-prefs

An offline engine (--offline: a test suite's engines, a probe, an engine an agent starts to check something) serves no human, so it keeps a choice for its own run instead: it boots with no choice, whatever any other engine on the machine chose, and its own choice holds until it stops and reaches no other engine. i18n.sources().choiceKept reads run there and device everywhere else. A test that needs a locale chooses it for itself.

Following changes

local id = i18n.onChange(function(locale, preferred)
    refreshLabels(locale)
end)
i18n.offChange(id)

A subscription made from a component ends with that component, and the callback runs in edit mode and play alike. The callback runs once per change, after the engine renegotiated: a platform language change while the engine runs (or an i18n.emulate), a choice made or cleared, the ZeroMind language moving, a locale launching, the pseudo-locale switching, or an edit to a catalog file this VM read text from. Screens built from i18n.text values have redrawn by then. The locale it receives is already the one i18n.locale() answers, and i18n.pick inside it answers for the new state.

Where else the locale goes

  • Every request the engine sends ZeroMind on the player's behalf carries the chosen locale in the x-zeromind-locale header, the same header the web app's own requests carry.
  • The text system picks its fallback fonts for the chosen locale (the regional glyph forms of a script follow it); /zero/runtime/text/locale reads the locale it uses.