i18n-nextjs
Internationalization (i18n) guide for Next.js / Node.js web applications using the App Router. Covers translation file structure, locale routing, SEO metadata per locale, hreflang, structured JSON-LD data, UI component translations, and multi-language sitemap generation. Use when the user asks to: add i18n support, add a new language, translate a page or component, add SEO metadata for multiple locales, implement hreflang, update the sitemap for new locales, or follow i18n best practices in a Next.js project.
- License 许可
- MIT
- 最近更新
- 2026-06-07
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- i18n-nextjs
- description
- Internationalization (i18n) guide for Next.js / Node.js web applications using the App Router. Covers translation file structure, locale routing, SEO metadata per locale, hreflang, structured JSON-LD data, UI component translations, and multi-language sitemap generation. Use when the user asks to: add i18n support, add a new language, translate a page or component, add SEO metadata for multiple locales, implement hreflang, update the sitemap for new locales, or follow i18n best practices in a Next.js project.
03 SKILL.md 正文
i18n for Next.js — Implementation Guide
Core Principles
- All user-facing features must implement i18n — no hardcoded strings in components.
- Translations must be natural and idiomatic — never use scripts or machine translation; treat quality the same as English copywriting.
- SEO metadata, JSON-LD structured data, and sitemaps must all be locale-aware.
- Default locale (English) uses clean URLs with no prefix (
/products); other locales use a prefix (/es/products).
Supported Locales
Locale list lives in src/lib/i18n/locales.ts. Keep the sitemap script's locales array in sync with this file.
export const locales = ['en', 'es', 'fr', 'de', 'ja', 'zh-CN', /* ... add as needed */]
export const defaultLocale = 'en'
export type Locale = typeof locales[number]
Directory Structure
src/app/[lang]/
├── dictionaries/ ← One JSON file per locale
│ ├── en.json
│ ├── es.json
│ └── ...
├── dictionaries.ts ← getDictionary(locale) server helper
├── layout.tsx ← Root layout: generateMetadata + hreflang + JSON-LD
└── <page>/
└── page.tsx ← generateMetadata + page content
Translation Files
See references/translation-files.md for:
- JSON key hierarchy conventions (
page.section.key) - Server-side
getDictionary()usage - Client-side
useDictionary()hook usage - Template variable pattern (
{count}substitution) - Fallback pattern for missing keys
Routing & Middleware
See references/routing.md for:
src/middleware.ts— locale detection, redirect/en/*→/*, rewrite for default localeLocalizedLinkcomponent — automatically prefixes non-default localesuseLocale()hook — reads locale from URL params → pathname → localStorage → defaultgetLocalizedPath()/removeLocalePrefix()utilities
SEO Metadata
See references/seo-metadata.md for:
generateMetadata()pattern in layout/page filesgenerateAlternatesMetadata()fromsrc/lib/i18n/seo.ts- Full hreflang
alternates.languagesoutput (all locales +x-default) - OpenGraph
locale/alternateLocalefields html langattribute andLangSetterclient component
Structured JSON-LD Data
See references/structured-data.md for:
- WebApplication schema with translated
featureList,description - BlogPosting schema with
inLanguagefield - FAQ schema with translated
acceptedAnswer - BreadcrumbList schema with localized URLs
- Rendering via
<Script>or<script>tags
Multi-language Sitemap
See references/sitemap.md for:
- Sitemap structure: one
<url>entry per page with<xhtml:link>alternates for every locale <loc>uses the default-locale (clean) URL;x-defaultalso points there- Full XML example with static and dynamic pages
- Next.js App Router
sitemap.tsimplementation pattern - What to include vs. exclude (admin/API routes excluded)
- Hreflang language code format rules
Quick Checklist — Adding a New Feature with i18n
- Add translation keys to all locale JSON files in
src/app/[lang]/dictionaries/- Add English first, then translate to all other languages naturally
- Server components:
const dict = await getDictionary(locale)→dict?.page?.section?.key || 'fallback' - Client components:
const dict = useDictionary()→ same fallback pattern - Add
generateMetadata()to the page file, callinggenerateAlternatesMetadata() - Add JSON-LD structured data script tag with translated fields and
inLanguage - Update sitemap if the page is new: add it to the sitemap source (see references/sitemap.md)
- Use
<LocalizedLink>for internal links andgetLocalizedPath()for programmatic navigation
Quick Checklist — Adding a New Locale
- Add locale code to
localesarray insrc/lib/i18n/locales.ts - Add locale entry to
dictionaries/as<code>.json(full translation ofen.json) - Add entry in
src/app/[lang]/dictionaries.tsimport map - Add display name in
LanguageSwitcherlanguageNamesmap - Sync the sitemap locale list with the app's
localesarray - Regenerate / redeploy the sitemap
04 同仓库更多 Skills
crowd-prompting
A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.
ceaser
Interact with the Ceaser privacy protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- shield, unshield, note management, and protocol queries. All ceaser tool calls use CLI subcommands (npx -y ceaser-mcp <subcommand>). Ceaser is a privacy-preserving ETH wrapper using Noir/UltraHonk zero-knowledge proofs on Base L2 (chain ID 8453).
ceaser-send
Fully automated private ETH transfer via Ceaser Protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- all ceaser tool calls use CLI subcommands (npx -y ceaser-mcp <subcommand>). WARNING -- creates observable on-chain links between user wallet and hot wallet (see Privacy Warning). Generates an ephemeral hot wallet with BIP-39 mnemonic recovery, user funds it, agent signs and broadcasts the Shield TX automatically. Exactly one manual step required (funding the hot wallet with ETH). Uses Noir/UltraHonk zero-knowledge proofs.
dilemm-ai
Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).
moldium
Post and manage content on the Moldium blog platform. Triggered by "post to Moldium", "write a blog post", "publish an article", etc.
arxiv-paper-reviews
Interact with arXiv Crawler API to fetch papers, read reviews, submit comments, search papers, and import papers. Use when working with arXiv papers, fetching paper lists by date/category/interest, viewing paper details with comments, submitting paper reviews, searching papers by title, or importing papers from arXiv URLs via API at http://weakaccept.top:8000/.