Components

<i18n-switcher>

The <i18n-switcher> component is a dropdown of the enabled locales, each linking to the current page in that locale.

<i18n-switcher> renders a button with the active locale and a dropdown of all enabled locales, including the active one. Use it for a ready-made language menu; build your own from $getLocales and $switchLocalePath when you need different markup. Each entry links to the current page in that locale.

Props and slots

Slots

Behaviour

  • Lists every locale without disabled: true, the active one included.
  • Each entry is an <a> to $switchLocalePath(code). A path resolves under app.baseURL; a locale baseUrl on another domain stays absolute. It has hreflang and lang set to iso || code, dir when the locale has one, aria-current="page" on the current locale, and class switcher-locale-<code>. A click calls $switchLocale(code) and closes the dropdown; with a modifier key it is left to the browser.
  • The list stays in the server HTML, hidden, so crawlers see the links. Escape or a click outside closes it.
  • Label: customLabels[code], then the locale's displayName, then the code (with a dev warning).
  • Styles: small inline defaults (bordered white button and panel, the active entry bold and blue). Each custom*Style prop is applied after the default of its part. The button has the classes i18n-switcher-button and language-switcher, the wrapper i18n-switcher-wrapper, the list i18n-switcher-dropdown. Positions use logical CSS properties, so dir="rtl" works.

Example

<template>
  <i18n-switcher
    :custom-labels="{ en: 'English', de: 'Deutsch' }"
    :custom-button-style="{ borderRadius: '4px' }"
  >
    <template #before-link-content="{ locale }">
      <img :src="`/flags/${locale.code}.svg`" alt="" width="16" />
    </template>
  </i18n-switcher>
</template>

$switchLocale

<i18n-link>