admin管理员组文章数量:1123202
I am using next-intl to handle translations in my Next.js application. From my understanding, next-intl typically performs translations on the server side. However, I want to store the user's language (locale) preference in localStorage (client-side) and use that value to translate my website.
My goal is to:
Make the translation run entirely on the client side. Keep the translation logic within the components. I do not want to use cookies or rely on i18n routing for this functionality.
I followed the example provided in the official documentation: next-intl without i18n routing. However, this example assumes the locale is determined differently.
The translation works fine on it's own and I have a button to toggle between two languages which works fine to change the localStorage value as well, it's just linking the two together that's giving me a hard time.
How can I modify my setup to achieve client-side translations while respecting the user's locale stored in localStorage?
I followed the next-intl without i18n routing example to set up translations : /docs/getting-started/app-router/without-i18n-routing
本文标签:
版权声明:本文标题:typescript - How to use localStorage to store language preferences and translate a website with next-intl in Next.js - Stack Ove 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736555599a1944572.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论