i18n Setup
NuxtBase ships with two locales in the app:
enzh
The routing strategy is:
prefix_except_defaultThat means:
- English stays on the default unprefixed routes
- Chinese uses the
/zhprefix
What This Means in Practice
Section titled “What This Means in Practice”Examples:
/login/pricing/docsare the default English routes, while the Chinese versions look like:
/zh/login/zh/pricing/zh/docsThis is a sensible default for English-first products that still want a clean second locale.
Where Locale Configuration Lives
Section titled “Where Locale Configuration Lives”| File | Purpose |
|---|---|
nuxt.config.ts | registers locales and the routing strategy |
i18n/i18n.config.ts | date and time formatting rules |
i18n/locales/en.json | English UI strings |
i18n/locales/zh.json | Chinese UI strings |
The important Nuxt config shape is:
locales: [ { code: "en", language: "en-US", name: "English", file: "en.json" }, { code: "zh", language: "zh-CN", name: "中文", file: "zh.json" },],defaultLocale: "en",strategy: "prefix_except_default";UI Copy Translation
Section titled “UI Copy Translation”Most interface strings are stored in:
i18n/locales/en.jsoni18n/locales/zh.json
When you change product wording, make the change in both files unless you intentionally want one locale to diverge.
This includes common areas like:
- navigation
- auth screens
- settings
- admin text
- email-adjacent UI labels
Locale Switching
Section titled “Locale Switching”The template includes a locale switcher component that builds links from the active locale list and the Nuxt i18n switch helper.
This means you usually do not need to hand-build locale URLs in UI components. Reuse the existing locale utilities and switcher behavior.
Docs Content in the App
Section titled “Docs Content in the App”Inside the core template, the in-app docs content is stored as separate content collections:
docs_endocs_zh
Those collections map to:
content/docs/en/**content/docs/zh/**
and are exposed with these route prefixes:
- English docs:
/docs - Chinese docs:
/zh/docs
That separation keeps translated docs content explicit and predictable.
Blog Content in the App
Section titled “Blog Content in the App”The same principle applies to blog content when you want both English and Chinese blog posts in the app.
Keep localized blog content explicit instead of mixing two languages into one post file.
That means:
- English blog routes should stay under
/blog - Chinese blog routes should use
/zh/blog - translated blog posts should be maintained as separate localized content entries
This gives you a clean split between:
- English-first marketing and SEO pages
- Chinese blog discovery pages
- per-locale blog copy, titles, descriptions, and metadata
If you only have bandwidth for one blog language at launch, keep the second locale out of the blog until you are ready to maintain it properly. Partial blog translation usually creates a worse experience than clearly shipping one complete language first.
Date and Time Formatting
Section titled “Date and Time Formatting”Locale-specific date formats are defined in i18n/i18n.config.ts.
Examples:
- English short dates use month names like
Apr 1, 2026 - Chinese short dates use numeric formatting
If you want locale-aware dates across the app, extend that config instead of formatting dates ad hoc in random components.
Recommended Customization Sequence
Section titled “Recommended Customization Sequence”- keep English as the default locale unless you have a strong reason to change it
- update branding and product naming in both locale files
- test the locale switcher in the UI
- verify route prefixes behave correctly under
/zh - only then expand translated docs, blog content, or product copy
Common Mistakes
Section titled “Common Mistakes”Updating Only One Locale File
Section titled “Updating Only One Locale File”This creates obvious quality gaps and makes the app feel unfinished.
Hardcoding /zh Paths in Components
Section titled “Hardcoding /zh Paths in Components”Prefer Nuxt i18n helpers and the existing locale switch flow instead of hand-building locale URLs.
Mixing Product Copy With Docs Structure
Section titled “Mixing Product Copy With Docs Structure”The app locale JSON files are for UI strings. Docs and blog content should live in their own localized content structures. Keep those responsibilities separate.