vue-storefront
vue-storefront copied to clipboard
fix(core): allow disabling locale redirects
Description
I think it would be a good idea to leave the door open for preventing locale redirects in vsf applications.
Last month we overwrote the default i18n
locale redirects logic in the i18nCookiesPlugin
. It detects the browser locale and redirects to it unconditionally (provided that it's one of the locales available in the VSF application). It happens even if the detectBrowserLanguage
option is set to false
.
My proposition here is to give our customers the ability to prevent redirects by setting the detectBrowserLanguage
to false
. And - to prevent generating the cookies by the i18n
library - use the following configuration:
i18n: {
detectBrowserLanguage: {
useCookie: false
}
}
It's the approach suggested by the nuxt-i18n documentation:
Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
- [x] I have read the CONTRIBUTING document.
Changelog
- [z] I have updated the Changelog (V1) v2 and mentioned all breaking changes in the public API.
- [ ] I have documented all new public APIs and made changes to existing docs mentioning the parts I've changed so they're up to date.
Tests
- [ ] I have written test cases for my code
- [x] I have tested my Pull Request on production build and (to my knowledge) it works without any issues
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
I tested manually my code, and it works well with both:
- [ ] Default Theme
- [ ] Capybara Theme
Code standards
- [ ] My code follows the code style of this project.
- [x] I have followed naming conventions
Docs
- [ ] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly.
:blue_heart: vsf-next-demo successfully deployed at
I would like to add the possibility to not update the currency also because the current version is also updating the currency cookie based on the browser locale.
I would like to add the possibility to not update the currency also because the current version is also updating the currency cookie based on the browser locale.
It will be resolved in another task
Hello, I tried to disable the accepted languages of the browser by adding this in my code :
i18n: { localeDetection: false, detectBrowserLanguage: false, }
But it doesn't work
The proposed fix seems incomplete to me:
Even if no redirect is sent,app.i18n.cookieValues
will still store the targetLocale
. I think a better approach would be to set targetLocale
to i18nOptions.defaultLocale
if i18nOptions.detectBrowserLanguage
is false and have a different option to disable redirects to i18n targets
Also if (redirectPath && i18nOptions.detectBrowserLanguage)
does work as proposed, if it is set to false as it was before
Closed due to inactivity