2022-11-28 06:58:29 +00:00
|
|
|
<script lang="ts" setup>
|
2022-11-28 07:12:13 +00:00
|
|
|
import { STORAGE_KEY_LANG } from '~/constants'
|
2022-11-28 06:58:29 +00:00
|
|
|
|
|
|
|
const { locale } = useI18n()
|
2022-11-28 07:12:13 +00:00
|
|
|
useLocalStorage(STORAGE_KEY_LANG, locale)
|
|
|
|
|
2022-11-28 10:24:05 +00:00
|
|
|
// TODO: read from $i18n https://i18n.nuxtjs.org/lang-switcher
|
2022-11-28 06:58:29 +00:00
|
|
|
const languageList = [
|
|
|
|
{
|
|
|
|
value: 'en-US',
|
|
|
|
label: 'English',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 'zh-CN',
|
|
|
|
label: '简体中文',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<CommonTooltip placement="bottom" content="Select Language">
|
|
|
|
<CommonDropdown>
|
2022-11-28 07:16:22 +00:00
|
|
|
<button flex>
|
2022-11-28 06:58:29 +00: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>
|