-
Notifications
You must be signed in to change notification settings - Fork 234
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
fix: i18n in app router #496
fix: i18n in app router #496
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
<strong className="font-medium">xLog</strong> is the best{" "} | ||
<UniLink | ||
<a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, In RSC, we shouldn't use components that may be both pure function component and stateful component (next/link) like <UniLink/>
, so I just replace to anchor tag here
|
||
import { Trans, useTranslation } from "next-i18next" | ||
import { useRouter } from "next/navigation" | ||
import { Element, Link } from "react-scroll" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we cant use class component in RSC so replace it to native anchor
@@ -12,6 +12,7 @@ export default async function HomeLayout({ | |||
}) { | |||
return ( | |||
<> | |||
{/* @ts-expect-error RSC */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,142 @@ | |||
"use client" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some component in @crossbell/ui
cause RSC error
part of #492
fix i18n problem
For client component => use props to display translated text , see
src/app/(home)/components/EntranceButton.tsx
(maybe there are better way)For server components just add a hook to get
headers['accept-language']
as langId and use it in async component withuseTranslation
insrc/lib/i18n
or<Trans/>
export fromreact-i18next/TransWithoutContext