-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Translations do not work on the first render of Client component when used in Layout #75
Comments
@aralroca I think it is very common use case, since you will want to have Navigation component in the layout. And it has to be a client component since it is using Link component. |
Thanks to report it @bluelakee02. Looks weird, is rendering the Plugin code: next-translate-plugin/src/templateAppDir.ts Line 129 in 3d6a504
Logs: |
@aralroca well, after some testing, I think it is caused by this: next-translate-plugin/src/templateAppDir.ts Lines 166 to 171 in f5a4c59
|
This |
@aralroca sorry, I linked wrong part - the same code is also in RSCPage |
next-translate-plugin/src/templateAppDir.ts Lines 106 to 111 in f5a4c59
but I think it is not necessary now since
https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes#convention |
@aralroca yeah, but the new next is acting weird when using [lang] in the app directory |
@aralroca I have made a custom solution that works on app dir nextjs 13
Routing is done via middleware, I have just one language at the moment but planning to use ?lang=secondLang in the future if you are interested I would suggest to make a lightweight package targeted on app router usage doing just this, it is the only way I made it work and be stable for production app. I could prepare it and you would think about how to intergrate with current solution. |
Any update on this one @aralroca? It would be really helpful if we can create a test suite for this case. |
I suggested a solution here aralroca/next-translate#1173 (comment) |
What version of this package are you using?
2.6.1
What operating system, Node.js, and npm version?
latest
I have created a code sandbox
link
just go there and type /test to the end of url of the app and hit Enter
as a temporary solution I am using this workaround:
const label = globalThis.__NEXT_TRANSLATE__ ? t(href) : fallbackImportedJSON[href];
because NEXT_TRANSLATE is missing on the first render
I tried to look at the code, but could not find a solution.
Are you willing to submit a pull request to fix this bug?
yes
The text was updated successfully, but these errors were encountered: