From 2ea18eb8a64a259470f8e2ecc98e9d7698c396d7 Mon Sep 17 00:00:00 2001 From: Alexandr SaVBaD Waltz Date: Sat, 28 Feb 2026 22:38:45 +0300 Subject: [PATCH] feat(storefront): refactor i18n and cart/wishlist handling for improved user experience Refactored i18n configuration, replacing `DEFAULT_LOCALE` with `DEFAULT_LOCALE_FALLBACK` and enhancing environment-based locale validation. Improved cookie persistence for cart and wishlist, ensuring fallback handling for unauthenticated users. Enhancements: - Added `createProjectKey` utility for consistent project key generation. - Reworked cart and wishlist composables (`useOrderOverwrite`, `useWishlistOverwrite`) to decouple product identifier and handle cookies robustly. - Centralized `DEFAULT_LOCALE` logic for better maintainability. - Refined `useOrderSync` and `useWishlistSync` for clean synchronization across auth states. - Updated SCSS in hero and header styles for alignment corrections. Breaking Changes: `DEFAULT_LOCALE` constant removed; replaced with runtime config and fallback logic. Consumers must adapt to `DEFAULT_LOCALE_FALLBACK` and `$appHelpers.DEFAULT_LOCALE`. --- storefront/app/app.config.ts | 3 +- storefront/app/app.vue | 11 +- .../app/components/base/header/index.vue | 7 +- storefront/app/components/cards/product.vue | 75 ++++++--- storefront/app/components/home/hero.vue | 1 + storefront/app/composables/auth/useLogin.ts | 5 +- storefront/app/composables/auth/useRefresh.ts | 3 +- .../app/composables/languages/useLanguage.ts | 4 +- .../languages/useLanguageSwitch.ts | 3 +- .../languages/useLocaleRedirect.ts | 6 +- .../composables/orders/useOrderOverwrite.ts | 145 ++++++++++-------- .../app/composables/user/useUserUpdating.ts | 3 +- .../wishlist/useWishlistOverwrite.ts | 90 ++++++----- .../composables/wishlist/useWishlistSync.ts | 4 +- storefront/app/constants/i18n.ts | 8 +- storefront/app/pages/product/[slug].vue | 46 +++++- storefront/app/pages/profile/settings.vue | 7 +- storefront/app/pages/shop.vue | 1 - storefront/app/plugins/00.app-constants.ts | 10 +- storefront/app/stores/language.ts | 3 +- storefront/app/utils/transliterator.ts | 99 ++++++++++++ storefront/i18n/i18.config.ts | 41 +++-- storefront/nuxt-app.d.ts | 1 + storefront/nuxt.config.ts | 9 +- 24 files changed, 391 insertions(+), 194 deletions(-) create mode 100644 storefront/app/utils/transliterator.ts diff --git a/storefront/app/app.config.ts b/storefront/app/app.config.ts index 5414d2d5..978f1b57 100644 --- a/storefront/app/app.config.ts +++ b/storefront/app/app.config.ts @@ -1,9 +1,8 @@ -import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from '@appConstants'; +import { SUPPORTED_LOCALES } from '@appConstants'; export default defineAppConfig({ i18n: { supportedLocales: SUPPORTED_LOCALES, - defaultLocale: DEFAULT_LOCALE, }, ui: { showBreadcrumbs: true, diff --git a/storefront/app/app.vue b/storefront/app/app.vue index 32d20f4e..45aad876 100644 --- a/storefront/app/app.vue +++ b/storefront/app/app.vue @@ -38,7 +38,6 @@