Skip to content
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

fix: add missing sw-language-id header #1657

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

fix: add missing sw-language-id header #1657

wants to merge 5 commits into from

Conversation

mdanilowicz
Copy link
Collaborator

@mdanilowicz mdanilowicz commented Jan 30, 2025

Description

This pull request includes several changes to add the missing sw-language-id header property for API calls across multiple components and modules. The most important changes are grouped by theme as follows:

API Header Updates:

  • Added sw-language-id header property for API calls in useCart, useCategorySearch, useCheckout, useCustomerOrders, useInternationalization, and useLandingSearch composables. [1] [2] [3] [4] [5] [6]

Import and Context Updates:

  • Updated imports to include useSessionContext in various files to access languageIdChain. [1] [2] [3] [4] [5] [6]

Test Updates:

  • Updated tests to include the sw-language-id header property for API call expectations in useCart, useCategorySearch, useInternationalization, and useListing components. [1] [2] [3] [4]

Component-Specific Changes:

  • Added sw-language-id header property in SwContactForm.vue and App.vue components. [1] [2]

closes #1651

Type of change

ToDo's

Screenshots (if applicable)

Additional context

Copy link

vercel bot commented Jan 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
frontends-demo 🔄 Building (Inspect) Visit Preview Jan 31, 2025 7:34am
shopware-frontends-docs ✅ Ready (Inspect) Visit Preview Jan 31, 2025 7:34am

Copy link

pkg-pr-new bot commented Jan 30, 2025

Open in Stackblitz

@shopware/api-client

npm i https://pkg.pr.new/shopware/frontends/@shopware/api-client@1657

@shopware/api-gen

npm i https://pkg.pr.new/shopware/frontends/@shopware/api-gen@1657

@shopware/cms-base-layer

npm i https://pkg.pr.new/shopware/frontends/@shopware/cms-base-layer@1657

@shopware/composables

npm i https://pkg.pr.new/shopware/frontends/@shopware/composables@1657

@shopware/helpers

npm i https://pkg.pr.new/shopware/frontends/@shopware/helpers@1657

@shopware/nuxt-module

npm i https://pkg.pr.new/shopware/frontends/@shopware/nuxt-module@1657

commit: 63ec891

@mkucmus
Copy link
Collaborator

mkucmus commented Jan 30, 2025

why does API ignore the current session language set by PATCH /context and we need to pass it explicitly?

@mdanilowicz
Copy link
Collaborator Author

why does API ignore the current session language set by PATCH /context and we need to pass it explicitly?

It's not ignoring. The second tab request overrides this session language by a PATCH /context request, and when you get back to the first tab, you have language from the second tab. That is why we have to use this header

Copy link
Collaborator

@mkucmus mkucmus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a lot of work done down here 🔥 ⛑️ 🏅

TODO:

  • fix breadcrumbs for navigation because it still mixes the languages (when I refresh the page on the different language in a second tab - breadcrumbs at the first tab is in a wrong language)

TO CONSIDER:

  • as languageIdChain is broadly used now, it still tells nothing and the name might be confusing for developers, maybe we can alias it to something more clear and fancy?
  • maybe we can hook-in the apiClient instance and set sw-language-id globally for entire app?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

[BUG] Language context is broken for the multi language tabs
2 participants