internationalization - How to translate the not-found page in Next.JS - Stack Overflow

My website has translations, and I want to translate my error pages. But I translate my pages with a dy

My website has translations, and I want to translate my error pages. But I translate my pages with a dynamic route (/app/[locale]) and not-found.tsx must be at the root (app/not-found.tsx). I don't use any libraries for my internationalisation.


What I tried: I created a custom error page in my /app/[locale]/ folder at /app/[locale]/404/page.tsx.

Then, my middleware sends all the non-valid urls to /[locale]/404 with the right locale.

The problem is: I can't find a way to fire a 404 status code.


I tried to set the status code from the middleware, but then I can't redirect to my custom error page. (NextResponse.redirect doesn't support status codes).

I tried using use notFound() in 404/page.tsx, but then app/not-found.tsx is rendered and not 404/page.tsx.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745203325a4616458.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信