next-translate
next-translate copied to clipboard
Change language - compatibility with Next 13
What version of this package are you using?
2.6.2 (latest at this day)
What problem do you want to solve?
With Next 13 and app dir
compatibly is poor, specially when changing the language in current navigation.
import setLanguage from 'next-translate/setLanguage'
gives an error (even with a use client
directive):
Error: No router instance found.
You should only use "next/router" on the client side of your app.
Based on what I see on README note the workaround for now it to use a middleware that appends ?lang=es
to each navigation. And add "dynamic root directory" [lang]
Readme note : https://www.npmjs.com/package/next-translate#14-use-next-13-app-directory
What do you think is the correct solution to this problem?
Fix import setLanguage from 'next-translate/setLanguage'
to allow changing language programmatically.
The workaround provided in the readme note suggest changing the files structure of the project and depending on how the app is hosted and built this could require changes on all Links (add /lang path)