/products); other locales use a prefix (/es/products).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]
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
See references/translation-files.md for:
page.section.key)getDictionary() usageuseDictionary() hook usage{count} substitution)See references/routing.md for:
src/middleware.ts — locale detection, redirect /en/ → /, rewrite for default localeLocalizedLink component — automatically prefixes non-default localesuseLocale() hook — reads locale from URL params → pathname → localStorage → defaultgetLocalizedPath() / removeLocalePrefix() utilitiesSee references/seo-metadata.md for:
generateMetadata() pattern in layout/page filesgenerateAlternatesMetadata() from src/lib/i18n/seo.tsalternates.languages output (all locales + x-default)locale / alternateLocale fieldshtml lang attribute and LangSetter client componentSee references/structured-data.md for:
featureList, descriptioninLanguage fieldacceptedAnswer or tagsSee references/sitemap.md for:
entry per page with alternates for every locale uses the default-locale (clean) URL; x-default also points theresitemap.ts implementation patternsrc/app/[lang]/dictionaries/const dict = await getDictionary(locale) → dict?.page?.section?.key || 'fallback'const dict = useDictionary() → same fallback patterngenerateMetadata() to the page file, calling generateAlternatesMetadata()inLanguage for internal links and getLocalizedPath() for programmatic navigationlocales array in src/lib/i18n/locales.tsdictionaries/ as .json (full translation of en.json)src/app/[lang]/dictionaries.ts import mapLanguageSwitcher languageNames maplocales array共 1 个版本