Localization Overview
Configure StarterApp to localize optional marketing routes while the dashboard and home page remain English-only.
Localization Overview
StarterApp ships with an opt-in localization system powered by @starterapp/i18n-core and @starterapp/i18n-next. The default marketing experience (including /) stays English-only, but you can opt specific routes into localization—see /localized-page-example for a working sample.
English-First Default
Only English is enabled out of the box. Each app registers additional locales explicitly.
Quick Start
-
Import the shared preset.
apps/marketing/i18n.tsalready callscreateLocalizedExampleAppI18n("marketing"), which registers English + Spanish dictionaries and opt-ins/localized-page-example. -
Opt a route into localization. Use the exported
marketingRoutesregistry:marketingRoutes.register("/my-localized-route");When you need a bespoke dictionary, call
createAppI18nor build a helper similar to the packaged example and reuse it across apps. -
Wrap the page export with
createMarketingLocalizedPageso the provider and message loading are handled for you. See Adding a Localized Route for the full workflow:// app/(marketing)/example/page.tsx import { createMarketingLocalizedPage } from "~/i18n/server"; export default createMarketingLocalizedPage({ namespaces: ["example"], render: ({ locale, messages }) => { const t = createTranslator({ locale, messages, namespace: "example" }); return <Page translations={t} />; }, });The helper automatically loads
commonplus any additional namespaces, merges shared fallbacks, and wraps the result inStarterAppI18nProvider.
Routing Model
- Marketing home requests (
/or/<locale>) default to English; no provider is mounted there. - Opt-in routes (for example
/localized-page-example) usecreateMarketingLocalizedPage, which wires middleware negotiation, dictionary loading, and the provider automatically. - Other marketing routes stay English-only unless you opt into localization using the same helper.
- Dashboard routes are explicitly English and do not participate in locale negotiation.
Testing & Telemetry
Unit Tests
`packages/i18n-core` and `packages/i18n-next` cover negotiation, fallback chains, and navigation helpers.
Integration
`apps/marketing/__tests__/localized-example.integration.test.tsx` verifies middleware + rendering for English and Spanish.
Telemetry
`recordDictionaryFallback` surfaces runtime fallbacks so missing translations can be monitored.
Adding a New Locale
Extend the packaged helper (or create one with createAppI18n) to register your locale definition and dictionary loaders.
Register the localized route with the shared registry (marketingRoutes.register("/your-route")) so middleware knows to negotiate locales.
Wrap the page with createMarketingLocalizedPage, run integration tests, and confirm middleware behavior.