i18n.ts 380 B

12345678910111213141516
  1. import { notFound } from "next/navigation"
  2. import { getRequestConfig } from "next-intl/server"
  3. // 支持的语言列表
  4. const locales = ["en", "zh"]
  5. export default getRequestConfig(async ({ locale }) => {
  6. if (!locale || !locales.includes(locale)) notFound()
  7. return {
  8. locale,
  9. messages: (await import(`./messages/${locale}.json`)).default,
  10. }
  11. })
  12. export { locales }