2022-11-28 15:58:29 +09:00
|
|
|
<script lang="ts" setup>
|
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-28 19:24:05 +09:00
|
|
|
// TODO: read from $i18n https://i18n.nuxtjs.org/lang-switcher
|
2022-11-28 15:58:29 +09:00
|
|
|
const languageList = [
|
|
|
|
{
|
|
|
|
value: 'en-US',
|
|
|
|
label: 'English',
|
|
|
|
},
|
2022-11-29 01:41:58 +09:00
|
|
|
{
|
|
|
|
value: 'de-DE',
|
|
|
|
label: 'Deutsch',
|
|
|
|
},
|
2022-11-28 15:58:29 +09:00
|
|
|
{
|
|
|
|
value: 'zh-CN',
|
|
|
|
label: '简体中文',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
</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
|
|
|
|
v-for="item in languageList"
|
|
|
|
:key="item.value"
|
|
|
|
:checked="item.value === locale"
|
|
|
|
@click="locale = item.value"
|
|
|
|
>
|
|
|
|
{{ item.label }}
|
|
|
|
</CommonDropdownItem>
|
|
|
|
</template>
|
|
|
|
</CommonDropdown>
|
|
|
|
</CommonTooltip>
|
|
|
|
</template>
|