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

404 Page not translated #1235

Closed
samfromaway opened this issue Jun 2, 2021 · 2 comments
Closed

404 Page not translated #1235

samfromaway opened this issue Jun 2, 2021 · 2 comments

Comments

@samfromaway
Copy link
Contributor

samfromaway commented Jun 2, 2021

Describe the bug

Main Layout components are not translated on the 404 page.
On the 404 page shared components like header and footer are not translated as there is no way to add ...(await serverSideTranslations(locale, ['common'])), as getServerSideProps and getStaticProps are not allowed, and if I want to use getInitialProps I get an error Can't resolve 'fs' in '/node_modules/next-i18next/dist/commonjs'

Occurs in next-i18next version

"react": "17.0.2",
"next-i18next": "^8.4.0",
"next": "10.2.3"
I configured my next.config.js to use webpack 4

Steps to reproduce

Run a next.js app and add a custom 404 page.
In _app add a component like a footer and try to use the t() when on a 404 page.

Expected behavior

It translates

OS (please complete the following information)

All browsers

Additional context

As it seems from #1040 this is not an unusual bug, but I think it's not really an edge-case. The rest of the migration from v6 to v8 worked fine, but because of this reason. I can't use v8.

I don't know if the problem is because next-i18next says that the issue of next.js that they don't use getStatic/getServerSideProps in 404 and 500 pages. Or if the issue is that getInitialProps should work with ...(await serverSideTranslations(locale, ['common'])), and it doesn't. Or if the issue is something different. Maybe this issue could also be resolved by providing ...(await serverSideTranslations(locale, ['common'])), globaly for all pages (like proposed in other issues).

BTW thanks for the otherwise great project.

Any idea why this issue is and how to solve it?

@isaachinman
Copy link
Contributor

This was updated recently – you can use getStaticProps in custom error pages. Good luck!

@samfromaway
Copy link
Contributor Author

@isaachinman Ah great, it works thanks a lot especially to be that responsive. You made my day!

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

No branches or pull requests

2 participants