feat(composables): locale from context's languageInfo#2486
Merged
Maciek Kucmus (mkucmus) merged 5 commits intoJun 12, 2026
Conversation
…t/locale-from-context-languageinfo
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new useSessionContext().currentLocaleCode computed value sourced directly from the /context response (languageInfo.localeCode), and updates the Vue demo + starter templates to prefer this value for current-locale detection (with a fallback to the existing languageId→locale mapping).
Changes:
- Expose
currentLocaleCodefromuseSessionContext()(computed fromsessionContext.languageInfo.localeCode). - Update demo/starter templates to use
currentLocaleCodefirst, falling back togetLanguageCodeFromId(languageIdChain.value)for older backends. - Add unit tests verifying
currentLocaleCodebehavior whenlanguageInfois present/absent; add a changeset for a minor bump.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| templates/vue-starter-template/app/app.vue | Prefer locale detection via currentLocaleCode with fallback mapping. |
| templates/vue-demo-store/app/app.vue | Prefer locale detection via currentLocaleCode with fallback mapping. |
| packages/composables/src/useSessionContext/useSessionContext.ts | Add currentLocaleCode to the composable return API. |
| packages/composables/src/useSessionContext/useSessionContext.test.ts | Add tests covering currentLocaleCode derivation and absence behavior. |
| .changeset/current-locale-from-context.md | Document the new API and ship a minor version bump. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Comment on lines
+81
to
+84
| it("currentLocaleCode is undefined when the context has no languageInfo", () => { | ||
| const { vm } = useSetup(() => useSessionContext()); | ||
| expect(vm.currentLocaleCode).toBeUndefined(); | ||
| }); |
Patryk Tomczyk (patzick)
approved these changes
Jun 12, 2026
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.
What
Adds
useSessionContext().currentLocaleCode- the active locale (e.g.en-GB) readstraight from
/context(languageInfo). Demo + starter templates use it forcurrent-locale detection, with a fallback to the language-list mapping.
Why
improvement: avoids fetching the full language list just to map the current
languageId -> localeso we can have one call less.Note
Doesn't remove
readLanguages(still needed for the switcher UI + switching) - thisonly covers current-locale detection.
Changeset:
@shopware/composablesminor.