The template has app-level providers for language and theme state.
Language
The shared i18n provider (@zship/react-saas-core/i18n) owns:
- a broad locale list aligned with Nuxt (en, zh-CN, zh-TW, ja, ko, and more)
- product requirement for parity: full UI coverage for
en+zh-CN - cookie persistence (
zship_nextjs_locale) so server-rendered pages can read the locale - document
lang/dirupdates - typed translation keys grouped by shell / auth / dashboard / pricing / ai / legal / content
- API locale normalization for backend requests (
localeToApiLocale)
The root layout reads the locale cookie and renders <html lang> plus the initial message catalog, so the first paint is already localized. Switching locale writes the cookie and refreshes the server components.
URL strategy (current)
Default remains client locale (option A): no /zh-CN path prefix. Path-prefix routing (option B) is deferred; re-evaluate later if SEO needs locale-specific crawl URLs.
Docs localization
src/lib/content/docs.ts stores English as the base and optional zhCN field overrides for title/label/description/content. The docs UI resolves copy with the request locale.
Theme
src/lib/client/theme.tsx owns:
light,dark, andsystemmodes- localStorage persistence (
zship_nextjs_theme) data-themeandcolor-schemeupdates ondocument.documentElement
An inline script in the root layout applies the theme before first paint; the CSS keeps a prefers-color-scheme: dark fallback before the client provider hydrates.