DEV Community

Discussion on: 😱 Static HTML Export with i18n compatibility in Next.js 😱

Collapse
 
karrtopelka profile image
Max Plotitsyn

I am writing project with typescript, and cannot use type "any".
I want to ask you about getStatic file.
Can you please tell the type of ctx?
And also ns by default is array of strings, but in makeStaticProps you assign to ns an empty object, should I change empty object to an empty array?

Collapse
 
adrai profile image
Adriano Raiano

this is JavaScript, not TypeScript…
ns can be a string or an array of strings
ctx is coming from Next.js

Collapse
 
davi_dev profile image
Davi

hey can you share some demo code of this setup, i also want to setup this in Ts
Thanks in advance

Collapse
 
karrtopelka profile image
Max Plotitsyn

I switched to next-translate, because it's easier, you just keep small json config file and locales folder and that's it, nothing more

Thread Thread
 
filiplusnia profile image
Filip Luśnia

is next-translate compatible with next export?

Collapse
 
karrtopelka profile image
Max Plotitsyn

Made everything like in a tutorial, but now, when I try to run in development mode (also for build) I got this error:
error - ./node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:78:0
Module not found: Can't resolve 'fs'
Can you help please how to resolve this issue

Collapse
 
adrai profile image
Adriano Raiano

This seems to work: github.com/adrai/next-language-det...

provide a reproducible example and open a github issue

Collapse
 
filiplusnia profile image
Filip LuÅ›nia • Edited

I'm not sure about what causes the "fs" issue but it seems related to using getStaticProps in client components - move it to server component and pass the translation to the component which causes the error