@vue-storefront/nuxt 2.5.0 → 2.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,13 @@ const i18nCookiesPlugin = ({ $cookies, i18n, app, redirect }) => {
13
13
  }
14
14
  const cookieLocale = $cookies.get(cookieNames.locale);
15
15
  const cookieCurrency = $cookies.get(cookieNames.currency);
16
+ const cookieCountry = $cookies.get(cookieNames.country);
17
+ const autoChangeCookie = {
18
+ locale: true,
19
+ currency: true,
20
+ country: true,
21
+ ...i18nOptions.autoChangeCookie,
22
+ };
16
23
 
17
24
  const getCurrencyByLocale = (locale) =>
18
25
  i18n.numberFormats?.[locale]?.currency?.currency
@@ -70,19 +77,27 @@ const i18nCookiesPlugin = ({ $cookies, i18n, app, redirect }) => {
70
77
  throw new Error(`Following fields are missing in the i18n configuration: ${missingFields.join(', ')}`);
71
78
  }
72
79
 
73
- if (cookieLocale !== settings.locale) {
80
+ if ((cookieLocale !== settings.locale && autoChangeCookie.locale) || !cookieLocale) {
74
81
  $cookies.set(cookieNames.locale, settings.locale, cookieOptions);
75
82
  }
76
83
 
77
- if (cookieCurrency !== settings.currency) {
84
+ if ((cookieCurrency !== settings.currency && autoChangeCookie.currency) || !cookieCurrency) {
78
85
  $cookies.set(cookieNames.currency, settings.currency, cookieOptions);
79
86
  }
80
87
 
81
- !$cookies.get(cookieNames.country) && $cookies.set(cookieNames.country, settings.country, cookieOptions);
88
+ if ((cookieCountry !== settings.country && autoChangeCookie.country) || !cookieCountry) {
89
+ $cookies.set(cookieNames.country, settings.country, cookieOptions);
90
+ }
82
91
 
83
92
  i18n.onBeforeLanguageSwitch = (oldLocale, newLocale, isInitialSetup, context) => {
84
- $cookies.set(cookieNames.locale, newLocale, cookieOptions);
85
- $cookies.set(cookieNames.currency, getCurrencyByLocale(newLocale), cookieOptions);
93
+ if (autoChangeCookie.locale) {
94
+ $cookies.set(cookieNames.locale, newLocale, cookieOptions);
95
+ }
96
+
97
+ if (autoChangeCookie.currency) {
98
+ $cookies.set(cookieNames.currency, getCurrencyByLocale(newLocale), cookieOptions);
99
+ }
100
+
86
101
  window.location.href = context.route.fullPath;
87
102
  }
88
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-storefront/nuxt",
3
- "version": "2.5.0",
3
+ "version": "2.5.4",
4
4
  "description": "",
5
5
  "main": "lib/module.js",
6
6
  "scripts": {