One string catalog for every platform, and codes instead of prose
Context and problem
Eduardo wants his Spanish family to play Homefelt in Spanish (#138).
Until now every string was English and written separately on each platform: the web game had its
own wordings.ts, the apps their own text, and some messages came straight from the server or a
rules engine as English sentences. Translating that as it stood would mean finding and translating
the same sentence up to five times, and server English would still leak onto the screen.
The plan is docs/plans/i18n.md.
Options considered
- Native catalogs per platform:
.xcstringson iOS,strings.xmlon Android, JSON on the web, each written by hand. The closest to Reflex’s “no shared production code”. - One shared catalog, generated into each platform’s format, the way
bin/gen-themealready shares the design tokens. - An i18n library on the web (FormatJS, i18next) on top of either.
Decision
We chose option 2, with no library:
design/strings/en.json(and lateres.json) holds every user-facing string as an ICU message, keyed by area (table.draw,refusal.pileFrozen), each with a note for translators.bin/gen-stringsgenerates typed TypeScript for the web now; iOS (.xcstrings) and Android (strings.xml) outputs come with the apps’ localization. Its--checkmode runs inbin/test.- Messages are compiled into small functions at build time. Plurals and numbers use the platform’s
own
Intl.PluralRulesandIntl.NumberFormat: no parser and no new dependency. - Codes, not prose. Servers and rules engines answer with codes.
spec/errors.jsonlists every rule and server code, the build fails if one has no words in the catalog, and clients never show a server’s Englishmessage; an unknown code gets a generic catalog sentence. - A pseudo-locale (
en-XA, accented and longer) is used in tests, with checks that text is never clipped horizontally or vertically at phone width and Large text.
Consequences
- Good: each sentence is translated once per language, and every platform says the same thing.
- Good: a refusal or a server error can appear in any language, because only its code travels.
- Good: long Spanish text is caught by tests before anyone sees it; the first pseudo-locale run found a status line that scrolled out of view at Large text, fixed in #144.
- Bad: one more generator to maintain, and strings are now shared data across platforms. Like the design tokens, they are data, not logic, so Reflex’s rule still holds for code.
- Bad: every new user-facing string needs a key and a note, and a regenerate step.
More information
- Plan:
docs/plans/i18n.md. Epic: #138; L1, the catalog and the web game: #139, #144. - Related: 0001 Reflex, 0011 Spanish from Spain first.