Skip to content

Add locale for en and cn#51

Open
jojowhoooo wants to merge 1 commit into
sadmann7:mainfrom
jojowhoooo:locale
Open

Add locale for en and cn#51
jojowhoooo wants to merge 1 commit into
sadmann7:mainfrom
jojowhoooo:locale

Conversation

@jojowhoooo
Copy link
Copy Markdown
Contributor

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
Copy link
Copy Markdown

vercel Bot commented Jul 20, 2023

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

@sadmann7 first needs to authorize it.

@sadmann7
Copy link
Copy Markdown
Owner

thanks a lot, will merge soon

@jojowhoooo
Copy link
Copy Markdown
Contributor Author

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
Copy link
Copy Markdown
Owner

I was looking over it.

I requires an additional local folder.

Can it be done without any additional folder?

@jojowhoooo
Copy link
Copy Markdown
Contributor Author

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?

export const dynamic = "force-dynamic"

export default async function IndexPage() {
export default async function IndexPage({params: {locale}}) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

locale is string type{params: {locale: string}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants