Languages and locale formatting
Status: ruling 2026-11-03 (plan and reasoning: [../i18n-plan.mdnull).
Java: framework-ui (io.flowcatalyst.framework.ui.i18n). Go: go/ui/i18n in the go/ui module,
standard library only.
The mechanism for showing an application’s user interface in more than one language. English is the source language, the default, and the fallback for every message.
Rulings (decided 2026-11-03): build the mechanism; ship English and Afrikaans (a native speaker reviews it) as the showcase; more languages follow the market; flat JSON catalogs, not ICU MessageFormat.
1. Locale
Section titled “1. Locale”A BCP 47 tag (en, en-ZA, af, af-ZA). One per request, resolved once (section 3), carried in
the request context, and read from there by everything that renders.
2. Catalogs
Section titled “2. Catalogs”A catalog is one JSON file per language: an object of message key to message.
{ "kit.list.next": "Next", "kit.list.showing": "Showing {from} to {to} of {total}", "kit.list.rows": { "one": "{count} row", "other": "{count} rows" }, "validation.TOO_SHORT": "must be at least {min} characters"}- Keys:
[a-z0-9]+(\.[A-Za-z0-9_-]+)+, a namespace first:kit.(the UI kits),validation.<CODE>(validation codes, as in the http contract),flash.<key>(an application’s flashes), and the application’s own (app.by convention). - A message is a string, or a plural object whose keys are CLDR plural categories (
zero,one,two,few,many,other;otheris required). - Placeholders:
{name},name=[a-zA-Z][a-zA-Z0-9]*, replaced by the argument’s text. An argument that is not given leaves the placeholder as it is.{{and}}are a literal brace. Nothing else is syntax. - Plurals: a plural message selects its category from the argument
count(an integer or a decimal) by the language’s CLDR cardinal rule. The rules shipped:en,af(one: n = 1),zu(one: i = 0 or n = 1). A language without a rule usesen’s. A missing category falls back toother. - Layers: the kit catalog, then the application’s catalogs on top (an application may override
a kit message). Files live in the application under
i18n/<tag>.json; the kit’s are inui-kit/messages/<tag>.json, shared by the Java and Go kits and embedded by both. - Lookup and fallback, per key: the locale’s tag (
af-ZA), then its language (af), thenen. A key missing from English too renders the key itself and is a test failure (section 6).
3. Resolving the locale
Section titled “3. Resolving the locale”In this order, keeping the first that names a language the application supports:
- The user’s preference: an application-supplied function of the request (for FlowCatalyst
applications, the principal’s
locale). - The tenant’s default: an application-supplied function (the client’s default locale).
Accept-Language, by its quality order, matched on the full tag then the language.en.
The application declares its supported tags (always including en). Java: a LocaleResolver
configured on the UI module; Go: i18n.Middleware(i18n.Config{Supported, User, Tenant}) storing
the result for i18n.FromContext(ctx).
4. Using it
Section titled “4. Using it”- Java:
Messagesfrom the request,messages.t("kit.list.next"),messages.t("kit.list.rows", Map.of("count", n)); JTE templates get it from the page model. - Go:
i18n.T(ctx, "kit.list.next"),i18n.T(ctx, "kit.list.rows", i18n.Args{"count": n}). - The document’s
<html lang>is the resolved locale’s tag (both kits; today it is fixeden). - The kits: every user-visible string in the Java and Go kits (labels, aria-labels, titles,
placeholders, defaults of label props) comes from the
kit.namespace. A component prop that sets a label keeps working and wins over the catalog. The English catalog reproduces today’s text exactly, so English output does not change. - Validation: the kits render a field error from
validation.<CODE>with the error’s parameters as arguments, falling back to the error’s own message when the code has no key. - Flashes: a flash key’s message comes from
flash.<key>when the catalog has it, else from the message registered in code (today’s behaviour). - API responses do not change: error bodies keep their code and English
message.
5. Formatting dates, numbers and money
Section titled “5. Formatting dates, numbers and money”The server writes plain values (ISO 8601 UTC instants, plain decimal text, the measure contract’s
money and quantity) plus the resolved locale; the browser formats them with Intl:
LocalTime(both kits, existing) formats with the document’slanginstead of the browser default.- New:
LocalNumber(decimal),LocalMoney(money)(currency style, the currency’s minor units unless told otherwise),LocalQuantity(quantity)(value and the unit’s symbol). The server-rendered text inside the element is the plain value, so the page reads correctly without JavaScript. - No server-side locale formatting data (no CLDR tables, no
golang.org/x/text).
5a. Details settled by the build (amended 2026-11-03)
Section titled “5a. Details settled by the build (amended 2026-11-03)”- Flashes:
flash.<key>replaces a flash’s summary andflash.<key>.detailits detail, each only when the catalogs have it. - The resolved tag is a supported tag: the candidate if supported, else the first supported tag
of its language (
af-ZAasked,afsupported, givesaf), solangnever carries a region the application did not declare. - Layers across languages: lookup tries the tag, then its language, then
en; within one step the topmost layer (the application’s) wins. An application’s English override does not beat the kit’s Afrikaans for an Afrikaans reader. - English plurals follow CLDR: one when the integer part is 1 and there are no fraction digits
(
1.0isotherin English,onein Afrikaans). - Validation parameters: violations carry only path, code and message today. The helpers take
parameters from the caller, and a text that needs a parameter it was not given falls back to the
violation’s English message. Adding named parameters (
min,max,allowed) to the violation types offramework-httpandhttpfw/validateis the next step. - Components keep string props: a kit component’s error text is a string; translating it is the caller’s helper call, not a component prop.
- Third-party island texts (the diagram renderer’s, CodeMirror’s) and the brand name are not in the catalogs.
6. Checks
Section titled “6. Checks”- Every key in every catalog exists in
en; every placeholder in a translation exists in the English message; a plural object hasother. - Every key the kits use exists in
en(a test renders every kit component in English and fails on a raw key). - A report (not a failure) lists the English keys each other catalog has not translated.