ChangeLanguage.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <span class="inline-flex">
  3. <tippy ref="language" interactive trigger="click" theme="popover" arrow>
  4. <template #trigger>
  5. <span class="select-wrapper">
  6. <ButtonSecondary
  7. v-tippy="{ theme: 'tooltip' }"
  8. :title="$t('settings.choose_language')"
  9. class="pr-8"
  10. outline
  11. svg="languages"
  12. :label="`${
  13. $i18n.locales.find(({ code }) => code == $i18n.locale).name
  14. }`"
  15. />
  16. </span>
  17. </template>
  18. <div class="flex flex-col" role="menu">
  19. <NuxtLink
  20. v-for="(locale, index) in $i18n.locales"
  21. :key="`locale-${index}`"
  22. :to="switchLocalePath(locale.code)"
  23. @click="language.tippy().hide()"
  24. >
  25. <SmartItem
  26. :label="locale.name"
  27. :active-info-icon="$i18n.locale === locale.code"
  28. :info-icon="$i18n.locale === locale.code ? 'done' : null"
  29. />
  30. </NuxtLink>
  31. </div>
  32. </tippy>
  33. </span>
  34. </template>
  35. <script setup lang="ts">
  36. import { ref } from "@nuxtjs/composition-api"
  37. const language = ref<any | null>(null)
  38. </script>