1
0
forked from bot/app
LiteyukiBot/docs/components/scripts/i18n.ts
2024-09-01 18:25:37 +08:00

27 lines
578 B
TypeScript

import {useData} from "vitepress";
const i18nData = {
"zh": {
online: '当前在线',
offline: '离线',
total: '全球实例',
fetching: '获取中',
},
"en": {
online: 'Online',
offline: 'Offline',
total: 'Total',
fetching: 'Fetching',
}
}
export default function getText(key: string): string {
// 转换语言
// zh-Hans -> zh
// en-US -> en
if (useData().site.value.lang.includes('-')) {
return i18nData[useData().site.value.lang.split('-')[0]][key];
} else {
return i18nData[useData().site.value.lang][key];
}
}