fix(vendor): pass request locale to query.graph on vendor routes#1224
Draft
vholik wants to merge 1 commit into
Draft
fix(vendor): pass request locale to query.graph on vendor routes#1224vholik wants to merge 1 commit into
vholik wants to merge 1 commit into
Conversation
Vendor API routes called query.graph without the options argument, so the Medusa Translation Module never received a locale and sellers always saw base-language content even when translations existed. Add an applyVendorLocale middleware on /vendor/* that resolves the locale from the ?locale query param, the x-medusa-locale header, the lng cookie, or Accept-Language (in that order) and exposes it on req.locale. Forward req.locale to query.graph on the translatable catalog read routes (product categories, collections, product tags, product types, products). Closes #1171
vholik
marked this pull request as draft
July 9, 2026 15:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #1171
Medusa 2.17's Translation Module resolves translated fields only when a locale is passed as
query.graph's second (options) argument. The vendor panel's API routes callquery.graph({ ... })without the options argument, so no locale signal ever reaches the query — sellers always see base-language content even when translations exist and the store'ssupported_localesare configured.The framework only registers its locale middleware for the
/storenamespace, soreq.localeis never populated on/vendor/*requests either. Both halves of the problem needed fixing.Changes
applyVendorLocalemiddleware (packages/core/src/api/utils/apply-vendor-locale.ts), registered on/vendor/*. It resolves the request locale and setsreq.locale, mirroring the framework's store-side behaviour but with the resolution order requested in the issue:?locale=query parameter (stripped afterwards so it never leaks intofilterableFields)x-medusa-localeheaderlngcookie (set by the vendor panel language switcher)Accept-Languageheaderreq.localetoquery.graphon the translatable catalog read routes:product-categories(list + detail)collections(list + detail)product-tags(list + detail)product-types(list + detail)products(list + detail)With
req.localenow available on every vendor request, remaining routes can adopt the same pattern as needed.Testing
Added regression coverage in
integration-tests/http/product-categories/vendor/product-categories.spec.tsverifying the vendor category routes accept a?localequery param (without it leaking into filters) and thex-medusa-localeheader.Full end-to-end translation verification (create a translation via
POST /admin/translations/batch, thenGET /vendor/product-categorieswithx-medusa-locale: ar) requires thetranslationfeature flag enabled.