Language Switcher with Cookies
Answered
Bigheaded ant posted this in #help-forum
Bigheaded antOP
I wanted to create my own blog with this [tailwind template app](https://tailwind-nextjs-starter-blog.vercel.app/).
I somewhat implemented the "LanguageSwitch" function similar to the ThemeSwitch.
However the language doesnt seem to be saved throughout the interactions. Reloading the website or going into a different page causes the language to reset.
As an example I've modified 404 page to use the current language based on the data in
Code:
I somewhat implemented the "LanguageSwitch" function similar to the ThemeSwitch.
However the language doesnt seem to be saved throughout the interactions. Reloading the website or going into a different page causes the language to reset.
As an example I've modified 404 page to use the current language based on the data in
public/static/languages
folder: https://pastebin.com/8TTd67S6 (Yes, I made it client side. Otherwise I wouldnt be able to import the language at all) Code:
components/LanguageSwitch.tsx
: https://pastebin.com/TtSrEmzrcomponents/Language.tsx
: https://pastebin.com/YsueCLdXAnswered by Quokka
I recommend going with an i18n library like
next-intl
to avoid headaches instead.2 Replies
I recommend going with an i18n library like
next-intl
to avoid headaches instead.Answer
@Quokka I recommend going with an i18n library like `next-intl` to avoid headaches instead.
Bigheaded antOP
not-found.tsx
file and doesnt render it at all. Instead it renders the default 404 error.nvm Im stupid. Fixed it. Thanks, closing