sadmann7 / skateshop

An open source e-commerce skateshop build with everything new in Next.js.
https://skateshop.sadmn.com
MIT License
5.1k stars 731 forks source link

Add locale for en and cn #51

Open jojowhoooo opened 1 year ago

jojowhoooo commented 1 year ago

I have tried two solutions, next-intl and i18next, and ultimately chose next-intl.

The compatibility between i18next and Clerk was not ideal, and it also enforced explicitly displaying the locale information in the URL, which is a bad user experience.

While next-intl is currently being used as a temporary workaround for static rendering pages, as the next.js default solution, it is expected to improve over time.

notes: It is supposed that adding language switch buttons on the header or footer in the future, as well as complete all i18n fields. I can participate in supplementing and reviewing the Chinese part. Thanks to the author for providing such a great learning project.

Reference:

  1. https://next-intl-docs.vercel.app/docs/getting-started/app-router-client-components
  2. https://next-intl-docs.vercel.app/docs/getting-started/app-router-server-components
  3. https://clerk.com/docs/nextjs/middleware
  4. https://locize.com/blog/next-13-app-dir-i18n/
vercel[bot] commented 1 year ago

Someone is attempting to deploy a commit to a Personal Account owned by @sadmann7 on Vercel.

@sadmann7 first needs to authorize it.

sadmann7 commented 1 year ago

thanks a lot, will merge soon

jojowhoooo commented 1 year ago

Found an issue where, when the user is not logged in, switching languages in url will result in too many redirection prompts.

too many redirection prompts details as follows:

This page isn’t workinglocalhost redirected you too many times.
[Try clearing your cookies](https://support.google.com/chrome?p=rl_error&hl=en-US).
ERR_TOO_MANY_REDIRECTS

so i stop redirect in afterAuth. it works.

if (!auth.userId) {
  //  If user tries to access a private route without being authenticated,
  //  redirect them to the sign in page
  return
  //  url.pathname = "/signin"
  //  return NextResponse.redirect(url)
}
sadmann7 commented 1 year ago

I was looking over it.

I requires an additional local folder.

Can it be done without any additional folder?

jojowhoooo commented 1 year ago

I was looking over it.

I requires an additional local folder.

Can it be done without any additional folder?

You mean folder named as [locale]? or some else, can you list them out?