✓ Verified 💻 Development ✓ Enhanced Data

Web I18n Nextjs

Internationalization (i18n) guide for Next.js / Node.js web applications using the App Router.

Rating
5 (153 reviews)
Downloads
32,230 downloads
Version
1.0.0

Overview

Internationalization (i18n) guide for Next.js / Node.js web applications using the App Router.

Complete Documentation

View Source →

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.

typescript
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

text
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 locale
  • LocalizedLink component — automatically prefixes non-default locales
  • useLocale() hook — reads locale from URL params → pathname → localStorage → default
  • getLocalizedPath() / removeLocalePrefix() utilities

SEO Metadata

See references/seo-metadata.md for:

  • generateMetadata() pattern in layout/page files
  • generateAlternatesMetadata() from src/lib/i18n/seo.ts
  • Full hreflang alternates.languages output (all locales + x-default)
  • OpenGraph locale / alternateLocale fields
  • html lang attribute and LangSetter client component

Structured JSON-LD Data

See references/structured-data.md for:

  • WebApplication schema with translated featureList, description
  • BlogPosting schema with inLanguage field
  • FAQ schema with translated acceptedAnswer
  • BreadcrumbList schema with localized URLs
  • Rendering via

💻Code Examples

example.ts
export const locales = ['en', 'es', 'fr', 'de', 'ja', 'zh-CN', /* ... add as needed */]
export const defaultLocale = 'en'
export type Locale = typeof locales[number]
example.txt
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

Tags

#web_and-frontend-development #web

Quick Info

Category Development
Model Claude 3.5
Complexity One-Click
Author javainthinking
Last Updated 3/10/2026
🚀
Optimized for
Claude 3.5
🧠

Ready to Install?

Get started with this skill in seconds

openclaw install web-i18n-nextjs