next-intl-add-language
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseThis is a guide to add a new language to a Next.js project using next-intl for internationalization,
- For i18n, the application uses next-intl.
- All translations are in the directory .
./messages - The UI component is .
src/components/language-toggle.tsx - Routing and middleware configuration are handled in:
src/i18n/routing.tssrc/middleware.ts
When adding a new language:
- Translate all the content of to the new language. The goal is to have all the JSON entries in the new language for a complete translation.
en.json - Add the path in and
routing.ts.middleware.ts - Add the language to .
language-toggle.tsx
这是一份为使用next-intl进行国际化的Next.js项目添加新语言的指南
- 该应用使用next-intl实现国际化(i18n)功能。
- 所有翻译文件都位于目录中。
./messages - UI组件为。
src/components/language-toggle.tsx - 路由和中间件配置在以下文件中处理:
src/i18n/routing.tssrc/middleware.ts
添加新语言时的步骤:
- 将中的所有内容翻译为新语言。目标是让新语言的JSON文件包含所有条目,以实现完整翻译。
en.json - 在和
routing.ts中添加对应的路径配置。middleware.ts - 在中添加该语言选项。
language-toggle.tsx