How to make Lingui RSC translations work for "special" nextjs loading file? #2121
Replies: 3 comments
-
Hello and thanks for asking! However AFAIK loading.js file is just a sugar for using Suspense. So if you use Suspense directly you might be able to work around this. Hope this helps, |
Beta Was this translation helpful? Give feedback.
-
You need to call import { setI18n } from '@lingui/react/server'
setI18n( /*pass a lingui instance there */) You need to know what locale this request is using, this might be trickiest part depending on how to language switching is working for your app. You can consult with nextjs docs to get info how to read route params in the |
Beta Was this translation helpful? Give feedback.
-
I have currently worked around this by making loading.tsx a |
Beta Was this translation helpful? Give feedback.
-
I have the following file which is a special next loading.js file. I can't seem to get translations to work
You tried to use Trans in Server Component, but i18n instance for RSC hasn't been setup. Make sure to call setI18n in the root of your page.
Any feedback is welcome.
Beta Was this translation helpful? Give feedback.
All reactions