如何使用 next-intl 实现国际化 nextjs项目
2024/10/26小于 1 分钟
如何使用 next-intl 实现国际化
import { getRequestConfig } from "next-intl/server";
import { notFound } from "next/navigation";
import { routing } from "./routing";
export default getRequestConfig(async ({ requestLocale }) => {
const locale = await requestLocale;
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
if (!routing.locales.includes(locale as any)) {
notFound();
}
return {
messages: (await import(`../../messages/${locale}.json`)).default,
};
});