Translating the UI (Lingui)
The source language is English. Catalogs live in apps/web/locales/<locale>/messages.po; apps/web/lingui.config.ts lists the locales. Macros compile with @lingui/swc-plugin (Next) and @lingui/vite-plugin (Vitest), and .po files load through @lingui/loader, so there is no compile step.
SWC plugins are tied to the swc_core version inside Next. If a Next upgrade fails to load @lingui/swc-plugin, move the plugin to a release built for that Next version (plugins.swc.rs lists the pairs).
Where translation works
Only components rendered under app/(app)/layout.tsx have a locale: that layout reads the locale cookie and wraps the app in LinguiClientProvider. Do not wrap strings in components that also render outside it (marketing, login, shared components/ui) until that route group gets a provider too, or useLingui throws there.
Wrapping strings
Client Components:
import { Trans, useLingui } from "@lingui/react/macro";
const { t } = useLingui();
<ItemTitle><Trans>Dark mode</Trans></ItemTitle>
<Switch aria-label={t`Toggle dark mode`} />
<Trans>Sign in with {data.email}.</Trans>
Server Components and generateMetadata have no React context. Call initLingui() first in every page, layout, or metadata function that renders text, then use t(i18n):
import { t } from "@lingui/core/macro";
import { initLingui } from "@/utils/i18n/server";
const i18n = await initLingui();
return <PageHeader title={t(i18n)`Settings`} />;
<Trans> also works in Server Components after initLingui().
- Module-level constants (option lists, labels) can't call
tat import time. Define them withmsgfrom@lingui/core/macroand render withi18n._(descriptor)(const { i18n } = useLingui()). - Counts use
plural/<Plural>, nevercount === 1 ? ... : .... - In JSX, render counts with
<Plural>. Aplural()nested intas a direct JSX child compiles to the global i18n, which has no locale and throws in production;utils/i18n/macro-compile.test.tscatches it. - Keep whole sentences in one message, with JSX inside
<Trans>, rather than gluing fragments together. - Don't translate brand and product names (Slack, Gmail, Inbox Zero), user data, or values the server stores and compares.
- Wrapping a string keeps its English text, so Playwright specs that select by visible name keep working. Don't reword strings while wrapping them.
Catalogs
A PR that adds or changes UI strings in a translated area also translates them: run pnpm -F inbox-zero-ai intl:extract, fill the new entries in every locale's messages.po, and commit the catalogs with the code. Every build runs lingui extract-template first, so a string that was missed still renders in English instead of breaking.
When translating, keep every placeholder ({0}, {name}), numbered tag (<0>…</0>), and plural #, match the catalog's existing terms and tone, and keep short labels short. Check that pnpm -F inbox-zero-ai exec lingui extract reports 0 missing for the locale.
Adding a language
Add it to locales in lingui.config.ts, to LOCALES and LOCALE_LABELS in utils/i18n/locales.ts, and to the catalog imports and catalogs map in utils/i18n/server.ts. Then run intl:extract, translate the new catalog, and commit it.
Landing pages
Landing pages take their language from the URL, not the cookie, so they stay static. English keeps the plain URL; translations live at /<locale>/<path> (e.g. /es/pricing), which next.config rewrites to the internal app/(landing)/l/[locale] tree.
- Every landing page renders through
components/layouts/BasicLayout, passing itslocale. It activates that language for Server Components (initLandingLingui) and wraps the page in the client provider. Never callinitLingui()on a landing page. - Landing strings live in a separate small catalog,
locales/<locale>/landing.po(seeLANDING_SOURCESin lingui.config.ts), so marketing visitors don't download the app catalog. A landing component may only use messages from those sources. - Internal links use
LandingLink, which keeps the page language. A page counts as translated only once it's listed inutils/i18n/landing.ts; that list drives in-language links, hreflang alternates (getLandingAlternates) and the sitemap. - The private marketing submodule keeps its own catalog:
app/(marketing)/lingui.config.ts, extracted withpnpm exec lingui extract --config "app/(marketing)/lingui.config.ts".
Locale selection
The locale cookie, set by the Language setting in Settings, picks the language; without it the app is English. The browser's language is not used.