Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
| strategy: 'no_prefix', | ||
| detectBrowserLanguage: false, | ||
| detectBrowserLanguage: { | ||
| useCookie: true, |
There was a problem hiding this comment.
Since the app generally seems to utilise localStorage to persist user settings, it could be an idea to store the currently selected lang in useSettings alongside it instead of using cookies? That would allow for using the settings object to get the language in the app, whenever it's needed.
There was a problem hiding this comment.
That was my first thought, but after reading docs and asking AI I decided to go with the cookie solution because:
- Cookies are available server-side (attached to requests). Thought it was important, since the app uses SSR.
- This is the built-in persistence method, so I guess it's encouraged?
There was a problem hiding this comment.
Wouldn't you have hydration issues using localstorage?
There was a problem hiding this comment.
useLocalStorage I think only hydrates itself after mounted, meaning there shouldn't be a hydration mismatch
cookie is worse because we actually statically render much of the site, so we can't SSR based on a user's cookie
There was a problem hiding this comment.
At least having locale in a cookie would allow us to maybe, one day, fix that and SSR the correct locale. Why close the doors that could stay open 🤷🏻♂️
There was a problem hiding this comment.
Tbh considering that setting up cookie-based persistence is just a matter of changing the config, it shouldn't be too hard to switch between localStorage and cookies. If the localStorage is the best option at this time, and we can tolerate the one time language settings reset in case of switching to cookies, I'm happy to go with the localStorage.
There was a problem hiding this comment.
@wojtekmaj even so, I have a plan to fix the rendering of a SSG site... I just need to create the PR...
thanks @DDeenis - let's do localStorage for now
|
Updated to use settings ( |
Resolves #509
Haven't worked with
@nuxt/i18nbefore, feedback welcome 🙏