Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add locale for en and cn #51

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

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

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
Owner

thanks a lot, will merge soon

@jojowhoooo
Copy link
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
Owner

I was looking over it.

I requires an additional local folder.

Can it be done without any additional folder?

@jojowhoooo
Copy link
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?

@@ -29,7 +30,7 @@ import { Shell } from "@/components/shells/shell"
// Read more: https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
export const dynamic = "force-dynamic"

export default async function IndexPage() {
export default async function IndexPage({params: {locale}}) {
Copy link
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.

None yet

3 participants