nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.71k stars 478 forks source link

[WIP] feat: detect browser language from `localStorage` #2862

Closed BobbieGoede closed 6 months ago

BobbieGoede commented 6 months ago

๐Ÿ”— Linked issue

โ“ Type of change

๐Ÿ“š Description

This is still a work in progress!

Adds detectBrowserLanguage.useLocalStorage which can be set to string | undefined, when set to a string this will be used to attempt to retrieve stored language in localStorage on the client-side.

This could potentially be useful for projects that want to store language settings but are not able (or don't want to) to use cookies, as is the case for https://github.com/elk-zone/elk.

I think we may want to consider a similar pattern as the localeDetector we currently use for the server side translations feature.

๐Ÿ“ Checklist

BobbieGoede commented 6 months ago

Closing as I think the solution for this use case can and should be resolved differently, based on recommendations by Daniel and Joaquin I'll explore a different approach for SSG, inserting translations in the page while detecting and translating during hydration client-side, though I'm not sure yet when I will have time to work on it.