Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ export default defineNuxtConfig({
locales: currentLocales,
defaultLocale: 'en-US',
strategy: 'no_prefix',
detectBrowserLanguage: false,
detectBrowserLanguage: {
useCookie: true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's try that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my first thought, but after reading docs and asking AI I decided to go with the cookie solution because:

  1. Cookies are available server-side (attached to requests). Thought it was important, since the app uses SSR.
  2. This is the built-in persistence method, so I guess it's encouraged?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't you have hydration issues using localstorage?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

@wojtekmaj wojtekmaj Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🤷🏻‍♂️

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

@danielroe danielroe Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

cookieKey: 'npmx-locale',
fallbackLocale: 'en-US',
},
langDir: 'locales',
},
})
Loading