app/docs/components/scripts/i18nData.ts

27 lines
638 B
TypeScript
Raw Normal View History

2024-09-01 16:52:10 +08:00
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];
2024-09-01 17:20:33 +08:00
} else {
return i18nData[useData().site.value.lang][key];
2024-09-01 16:52:10 +08:00
}
}