Skip to content

feat(composables): locale from context's languageInfo#2486

Merged
Maciek Kucmus (mkucmus) merged 5 commits into
mainfrom
feat/locale-from-context-languageinfo
Jun 12, 2026
Merged

feat(composables): locale from context's languageInfo#2486
Maciek Kucmus (mkucmus) merged 5 commits into
mainfrom
feat/locale-from-context-languageinfo

Conversation

@mkucmus

Copy link
Copy Markdown
Contributor

What

Adds useSessionContext().currentLocaleCode - the active locale (e.g. en-GB) read
straight from /context (languageInfo). Demo + starter templates use it for
current-locale detection, with a fallback to the language-list mapping.

Why

improvement: avoids fetching the full language list just to map the current languageId -> locale so we can have one call less.

Note

Doesn't remove readLanguages (still needed for the switcher UI + switching) - this
only covers current-locale detection.

Changeset: @shopware/composables minor.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 currentLocaleCode from useSessionContext() (computed from sessionContext.languageInfo.localeCode).
  • Update demo/starter templates to use currentLocaleCode first, falling back to getLanguageCodeFromId(languageIdChain.value) for older backends.
  • Add unit tests verifying currentLocaleCode behavior when languageInfo is 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.

@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontends-starter-template-extended Ready Ready Preview, Comment Jun 12, 2026 8:22am

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

Comment on lines +81 to +84
it("currentLocaleCode is undefined when the context has no languageInfo", () => {
const { vm } = useSetup(() => useSessionContext());
expect(vm.currentLocaleCode).toBeUndefined();
});
@mkucmus Maciek Kucmus (mkucmus) merged commit 5678fb0 into main Jun 12, 2026
11 checks passed
@mkucmus Maciek Kucmus (mkucmus) deleted the feat/locale-from-context-languageinfo branch June 12, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants