nuxt3 icon indicating copy to clipboard operation
nuxt3 copied to clipboard

switchLocalePath

Open andrehrferreira opened this issue 4 years ago • 3 comments

is it possible to use the switchLocalePath function?

andrehrferreira avatar Dec 02 '21 17:12 andrehrferreira

I couldn't use SwitchLocalePath too. How to do switch locale ? Could you tell us example on Nuxt3 please

kazu80 avatar Jan 02 '22 01:01 kazu80

I’m forcusing on nuxt/i18n. And currently, I’m developing core library for nuxt/i18n and it will be able to use as vue plugin library.

kazupon avatar Jan 08 '22 01:01 kazupon

I wrote below code instead SwitchLocalePath

<script setup lang="ts">
import {useI18n} from "vue-i18n"
const i18n = useI18n()

const changeLocale = (locale: string) => {
  i18n.locale.value = locale
}
</script>

<template>
  <div class="lang-set">
    <ul>
      <li v-if="i18n.locale.value === 'ja'">
        <button class="lang-set-button__english" @click="changeLocale('en')">English</button>
      </li>
      <li v-else>
        <button class="lang-set-button__english" @click="changeLocale('ja')">日本語</button>
      </li>
    </ul>
  </div>
</template>

kazu80 avatar Feb 02 '22 00:02 kazu80