Architecture
Internationalization
Locales, URL routing, typed dictionaries, plurals, money and dates — and how to add a language.
A documentação técnica está em inglês.
Splitmize ships in Portuguese (default), English and Spanish. The whole system is about 150 lines in src/i18n/ and has no dependencies.
Routing
| URL | Locale |
|---|---|
/, /split, /docs/… | Portuguese |
/en, /en/split, … | English |
/es, /es/split, … | Spanish |
All pages live under src/app/[locale]/. src/proxy.ts:
- rewrites unprefixed paths to
/pt/…internally (the URL stays clean); - redirects
/pt/…to the unprefixed URL, so each page has one canonical address; - redirects an unprefixed visit to
/enor/esonly if the visitor explicitly picked that language before (cookiesplitmize-locale, set by the language switcher).
There is deliberately no Accept-Language sniffing: crawlers and shared links should get what the URL says. Each page declares hreflang alternates in its metadata.
Dictionaries
src/i18n/dictionaries/pt.ts is the source of truth. Its shape defines the Dictionary type, and en.ts / es.ts are typed against it — a missing or extra key is a compile error, not a runtime surprise.
const { t, tp, tag } = useI18n(); // client components
const { t } = createTranslator(locale); // server components
t('people.title') // "Quem tá na mesa?"
t('people.duplicate', { name: 'Ana' }) // interpolation with {name}
tp('receipt.people', 4) // "4 pessoas" — picks _one / _other
Keys are type-checked too: t('people.titel') doesn't compile.
Plurals
tp(key, count) looks up key_one or key_other using Intl.PluralRules. One deliberate deviation: CLDR files 0 under Portuguese "one" ("0 pessoa"), but people write "0 pessoas", so zero always uses _other.
Arrays
Structured copy (the landing page's steps, the features "menu") lives as arrays in the dictionary and is read directly from dict in Server Components.
Money and dates
Never format by hand. Use:
formatMoney(cents, currency, tag)→R$ 1.234,56,$1,234.56formatAmount(...)→ number only, for receipt columnsformatBillDate(iso, tag)→14 nov 2026 · 21:40
tag is the BCP 47 tag from localeMeta (pt-BR, en-US, es).
Currency is independent of language. A new bill's currency is guessed from the browser language that matches the page language (pt-PT → EUR, es-MX → MXN), falling back to the language default (pt → BRL, en → USD, es → EUR). The choice is saved as the default for later bills.
Adding a language
- Add the code to
localesand an entry tolocaleMetainsrc/i18n/config.ts(label, short code, BCP 47 tag, Open Graph locale, default currency). - Create
src/i18n/dictionaries/<code>.tstyped asDictionary— copyen.tsand translate. TypeScript will list anything you missed. - Register it in
src/i18n/translate.ts. - Add the prefix to the
proxy.tsmatcher logic if it differs from the pattern (it readslocales, so usually nothing to do). - Run
npm run checkand open/<code>and/<code>/split.
The docs
Documentation pages are written in English and rendered under every locale prefix with localized navigation. Their canonical URL points to the /en/docs/… version so search engines index one copy. A per-locale override system can be added in src/lib/docs.ts if translated docs are ever needed.