2022-11-28 15:58:29 +09:00
|
|
|
<script lang="ts" setup>
|
2022-11-29 01:49:30 +09:00
|
|
|
import type { LocaleObject } from '@nuxtjs/i18n/dist/runtime/composables'
|
|
|
|
import type { ComputedRef } from 'vue'
|
2022-11-28 16:12:13 +09:00
|
|
|
import { STORAGE_KEY_LANG } from '~/constants'
|
2022-11-28 15:58:29 +09:00
|
|
|
|
2022-11-29 01:28:44 +09:00
|
|
|
const { locale, t } = useI18n()
|
2022-11-28 16:12:13 +09:00
|
|
|
useLocalStorage(STORAGE_KEY_LANG, locale)
|
|
|
|
|
2022-11-29 01:49:30 +09:00
|
|
|
const { locales } = useI18n() as { locales: ComputedRef<LocaleObject[]> }
|
2022-11-28 15:58:29 +09:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-11-29 01:28:44 +09:00
|
|
|
<CommonTooltip placement="bottom" :content="t('selectLanguage')">
|
2022-11-28 15:58:29 +09:00
|
|
|
<CommonDropdown>
|
2022-11-28 16:16:22 +09:00
|
|
|
<button flex>
|
2022-11-28 15:58:29 +09:00
|
|
|
<div i-ri:earth-line text-lg />
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<template #popper>
|
|
|
|
<CommonDropdownItem
|
2022-11-29 01:49:30 +09:00
|
|
|
v-for="item in locales"
|
|
|
|
:key="item.code"
|
|
|
|
:checked="item.code === locale"
|
|
|
|
@click="locale = item.code"
|
2022-11-28 15:58:29 +09:00
|
|
|
>
|
2022-11-29 01:49:30 +09:00
|
|
|
{{ item.name }}
|
2022-11-28 15:58:29 +09:00
|
|
|
</CommonDropdownItem>
|
|
|
|
</template>
|
|
|
|
</CommonDropdown>
|
|
|
|
</CommonTooltip>
|
|
|
|
</template>
|