next-intl-add-language

作者: github

使用next-intl国际化向Next.js应用添加新语言。需将./messages目录下en.json中的所有条目翻译为新语言,更新src/i18n/routing.ts中的路由配置和src/middleware.ts中的中间件以识别新语言,并在src/components/language-toggle.tsx的语言切换组件中注册该语言。

npx skills add https://github.com/github/awesome-copilot --skill next-intl-add-language

This 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.ts
    • src/middleware.ts

When adding a new language:

  • Translate all the content of en.json to the new language. The goal is to have all the JSON entries in the new language for a complete translation.
  • Add the path in routing.ts and middleware.ts.
  • Add the language to language-toggle.tsx.