Skip to content

feat(language): language switcher #172

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

Open
wants to merge 11 commits into
base: release/v0.2
Choose a base branch
from

Conversation

JacquelineKlimmek
Copy link
Contributor

@JacquelineKlimmek JacquelineKlimmek commented Jun 18, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a language switcher in the footer, allowing users to select their preferred language using a dropdown with flag emojis.
  • Enhancements
    • Improved route handling to ensure consistent navigation paths across different locales.
    • Updated app metadata to explicitly set the character encoding to UTF-8 for better compatibility.

Copy link

coderabbitai bot commented Jun 18, 2025

Walkthrough

A language switcher feature was introduced by adding new Vue components, a JSON asset mapping language codes to flag emojis, and updating the footer layout to include the switcher. Additional changes include improving route path handling to ensure a non-empty value and explicitly setting the document charset in the Nuxt configuration.

Changes

File(s) Change Summary
components/LanguageSwitcher.vue Added a new wrapper Vue component rendering LanguageSwitcherInner.
components/LanguageSwitcherInner.vue Added a Vue component implementing a language selection dropdown with emoji support.
assets/json/languageEmojis.json Added a JSON file mapping language ISO codes to flag emojis.
components/layout/footer/LayoutFooterInner.vue Inserted a named slot and default LanguageSwitcher in the footer layout.
pages/[...all].vue Modified route path assignment to ensure it defaults to '/' if empty or falsy.
nuxt.config.ts Added a UTF-8 charset meta tag to the Nuxt app's head configuration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LanguageSwitcher
    participant LanguageSwitcherInner
    participant UiSelect
    participant i18nUtils
    participant SessionContext

    User->>LanguageSwitcher: Render component
    LanguageSwitcher->>LanguageSwitcherInner: Render inner component
    LanguageSwitcherInner->>i18nUtils: Fetch available languages (onMounted)
    i18nUtils-->>LanguageSwitcherInner: Return list of languages
    LanguageSwitcherInner->>SessionContext: Get current language
    User->>UiSelect: Open dropdown and select language
    UiSelect->>LanguageSwitcherInner: onUpdate(selectedLang)
    LanguageSwitcherInner->>i18nUtils: changeLanguage(selectedLang)
    i18nUtils-->>LanguageSwitcherInner: Return redirect URL
    LanguageSwitcherInner->>User: Redirect browser to new URL
Loading
sequenceDiagram
    participant LayoutFooterInner
    participant LanguageSwitcher

    LayoutFooterInner->>LanguageSwitcher: Render in "language-switcher" slot
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee82184 and 8cf39b9.

📒 Files selected for processing (2)
  • assets/json/languageEmojis.json (1 hunks)
  • components/LanguageSwitcherInner.vue (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • assets/json/languageEmojis.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/LanguageSwitcherInner.vue
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: review-app

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
components/LanguageSwitcherInner.vue (1)

7-8: Top-level await may degrade TTI on CSR & block SSR rendering

The component does a blocking await getAvailableLanguages() before the template is evaluated.
If the request is slow, both CSR initial render and SSR streaming (Nuxt) are delayed.
Consider moving the call to an async onMounted/useAsyncData (Nuxt) hook or using Promise.all without await to let the component render a skeleton immediately.

components/LanguageSwitcher.vue (1)

1-3: Component is a no-logic passthrough – consider inlining

LanguageSwitcher.vue only re-exports LanguageSwitcherInner without adding props, provide/inject, or layout.
Eliminating the extra component avoids one level in the vnode tree:

-<template>
-    <LanguageSwitcherInner />
-</template>
+<!-- Remove this file and use <LanguageSwitcherInner /> directly -->

Nice-to-have, but keeps the tree flat.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c2f8f1 and 9fd559d.

📒 Files selected for processing (4)
  • components/LanguageSwitcher.vue (1 hunks)
  • components/LanguageSwitcherInner.vue (1 hunks)
  • components/layout/footer/LayoutFooterInner.vue (1 hunks)
  • pages/[...all].vue (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: review-app
🔇 Additional comments (3)
components/LanguageSwitcherInner.vue (1)

28-32: Pass the primitive, not the ref, to default-value

UiSelect most likely expects a primitive.
Passing the ref itself works only if the component unwraps refs (Vue will not do that automatically for props).
If UiSelect is not set up for ref-based props, use .value:

-<UiSelect :default-value="selectedLanguage" @update:model-value="onUpdate">
+<UiSelect :default-value="selectedLanguage.value" @update:model-value="onUpdate">
pages/[...all].vue (1)

18-20: LGTM – fallback ‘/’ guards against empty path

The additional || '/' correctly prevents downstream 404s when the stripped path is empty.
No further issues spotted.

components/layout/footer/LayoutFooterInner.vue (1)

52-56: LanguageSwitcher not imported – relies on global/auto-import

LanguageSwitcher is referenced in the template but isn’t imported in the <script setup>.
If the project stops auto-importing components in the future, this silently breaks SSR.
Add an explicit import (tree-shakable):

<script setup lang="ts">
 import type { Schemas } from '@shopware/api-client/api-types';
+import LanguageSwitcher from '~/components/LanguageSwitcher.vue';

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
stores/LocaleStore.ts (2)

4-6: Simplify the wrapper and propagate the promise.

loadAvailableLanguages does nothing beyond awaiting another async function.
Dropping the async/await removes an unnecessary micro-task and lets callers await the underlying promise (and catch errors) directly.

-    const loadAvailableLanguages = async () => {
-        await getAvailableLanguages();
-    };
+    const loadAvailableLanguages = () => getAvailableLanguages();

8-10: Consider whether a Pinia store is needed here.

This store has no state or getters—it only exposes a pass-through action to a composable.
Unless future state is planned, components could call useInternationalization().getAvailableLanguages() directly and avoid an extra abstraction layer.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7d42c2 and 8fa1745.

📒 Files selected for processing (2)
  • components/LanguageSwitcherInner.vue (1 hunks)
  • stores/LocaleStore.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/LanguageSwitcherInner.vue
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: review-app
🔇 Additional comments (1)
stores/LocaleStore.ts (1)

1-3: Verify that defineStore and useInternationalization are auto-imported.

There are no explicit imports for defineStore or useInternationalization.
If your build relies on an Auto-Import plugin (e.g. unplugin-auto-import) this is fine; otherwise the file will not compile.

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

Successfully merging this pull request may close these issues.

3 participants