-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cookie Value Error #2822
Comments
Would you be able to provide a reproduction? 🙏 More infoWhy do I need to provide a reproduction?Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making. What will happen?If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect. If How can I create a reproduction?We have a couple of templates for starting with a minimal reproduction: 👉 Reproduction starter (v8 and higher) A public GitHub repository is also perfect. 👌 Please ensure that the reproduction is as minimal as possible. See more details in our guide. You might also find these other articles interesting and/or helpful: |
I tried to reproduce it but failed, so I showed it as a picture. When the user sets the cookie value to a random value as in the picture and refreshes the page, it does not return to the default value. If the cookie value is en or tr, the system works perfectly. The part I don't understand here is why the default doesn't work when the user manually changes the cookie value. |
Based on your description it doesn't sound like a bug, of course editing cookies by hand to unexpected values will result in undefined behaviour. That said, I can see this happen in an edge case which could happen when a website removes a language which previously would have been saved in a cookie. In such cases it would make sense to redirect/fallback to the default language.
Did you try making it using stackblitz? You may need to open the preview in a new tab for the cookies to work. Even if I understood the issue correctly a reproduction would be useful for me to test a solution on (and add tests for it). |
I think I did. https://stackblitz.com/edit/github-kvjw8r-jgxyrr?file=nuxt.config.ts When the cookie value is changed manually, it does not return to the default value. How can I solve this problem? |
any update? |
Unfortunately I was busy with other issues and my day job, will look into this when I have the time. |
With #2841 merged the locale cookie should revert to the You can try it out on the edge channel ( |
I did the following steps. 1- npm i -D @nuxtjs/i18n@npm:@nuxtjs/i18n 2- I changed the cookie value to an irrelevant value and refreshed the page. I got the results in the picture above. I checked what you wrote, but I couldn't correct the mistake. DefaultLocale doesn't seem to be working or I couldn't do it. |
Oh I'm sorry, I made a mistake in the install command 😥 it should be |
My problem is solved. Thanks |
Environment
Reproduction
i18n: {
baseUrl: process.env.BASE_URL,
langDir: "locales/",
strategy: "no_prefix",
skipSettingLocaleOnNavigate: true,
defaultDirection: "ltr",
defaultLocale: "tr",
detectBrowserLanguage: {
useCookie: true,
fallbackLocale: "tr",
alwaysRedirect: true,
cookieSecure: true,
redirectOn: "root",
cookieKey: "lng"
},
locales: [
{
code: "tr",
iso: "tr-TR",
name: "Türkçe",
file: "tr.json",
dir: "ltr"
},
{
code: "en",
iso: "en-US",
name: "English",
file: "en.json",
dir: "ltr"
}
]
}
Describe the bug
I work with 2 languages, En and Tr, and I use cookies. It works great when my cookie value is en or tr, but when I change the cookie value manually, it should be tr but it doesn't work. What is my mistake?
i18n: {
baseUrl: process.env.BASE_URL,
langDir: "locales/",
strategy: "no_prefix",
skipSettingLocaleOnNavigate: true,
defaultDirection: "ltr",
defaultLocale: "tr",
detectBrowserLanguage: {
useCookie: true,
fallbackLocale: "tr",
alwaysRedirect: true,
cookieSecure: true,
redirectOn: "root",
cookieKey: "lng"
},
locales: [
{
code: "tr",
iso: "tr-TR",
name: "Türkçe",
file: "tr.json",
dir: "ltr"
},
{
code: "en",
iso: "en-US",
name: "English",
file: "en.json",
dir: "ltr"
}
]
}
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: