app/docs/components/scripts/i18n.ts

113 lines
3.5 KiB
TypeScript
Raw Normal View History

2024-09-01 20:39:51 +08:00
import {ref} from "vue";
2024-09-01 22:00:17 +08:00
2024-09-01 18:25:37 +08:00
import {useData} from "vitepress";
const i18nData = {
2024-09-01 20:39:51 +08:00
en: {
2024-09-01 22:30:46 +08:00
stats: 'Stats',
2024-09-01 20:39:51 +08:00
online: 'Online',
offline: 'Offline',
total: 'Total',
fetching: 'Fetching',
stars: 'Stars',
forks: 'Forks',
issues: 'Issues',
prs: 'Pull Requests',
2024-09-10 08:17:24 +08:00
visitors: 'Visitors',
2024-09-01 21:16:45 +08:00
size: 'Size',
plugins: 'Plugins',
resources: 'Resources',
2024-09-01 22:14:09 +08:00
pluginStore: 'Plugin Store',
pluginStoreDesc: 'Content from the LightSnow Plugin Store, LightSnow supports NoneBot through the lpnonebot plugin, and references some NoneBot plugins',
liteyukiOnly: 'Liteyuki Only',
search: 'Search',
resourceStore: 'Resources Store',
2024-09-04 02:43:44 +08:00
thx_contributors: 'Thanks the following contributors!',
2024-09-15 00:20:22 +08:00
easterEgg: 'Congratulations on finding the Easter egg!',
publishPlugin: 'Publish Plugin',
publishRes: 'Publish Resource',
closeButtonText: 'Close',
submitButtonText: 'Submit',
resName: 'Name',
resDesc: 'Description',
resAuthor: 'Author',
resLink: 'Download Link',
resHomepage: 'Homepage',
resNameText: 'Example: Kawaii Style Theme',
resDescText: 'Example: A kawaii style and color theme',
resAuthorText: 'Usually the github username, Example: yanyongyu',
resLinkText: 'Direct download link, usually zip package link',
resHomepageText: 'Optional, can be the name of the git platform repository"',
2024-09-01 20:39:51 +08:00
},
zh: {
2024-09-01 22:30:46 +08:00
stats: '统计信息',
2024-09-01 20:39:51 +08:00
online: '在线',
offline: '离线',
total: '实例',
fetching: '获取中',
2024-09-10 08:17:24 +08:00
stars: '星星',
2024-09-02 21:26:11 +08:00
forks: '分叉',
2024-09-10 08:17:24 +08:00
issues: '议题',
2024-09-05 11:45:12 +08:00
prs: '拉取请求',
2024-09-02 00:13:37 +08:00
visitors: '访客',
2024-09-01 21:16:45 +08:00
size: '大小',
plugins: '插件',
resources: '主题资源',
2024-09-01 22:14:09 +08:00
store: '商店',
pluginStore: '插件商店',
pluginStoreDesc: '内容来自轻雪插件商店轻雪通过lpnonebot插件对NoneBot实现支持引用了部分NoneBot插件',
liteyukiOnly: '仅轻雪',
search: '搜索',
resourceStore: '资源商店',
2024-09-04 02:43:44 +08:00
thx_contributors: '感谢以下贡献者!',
2024-09-15 00:20:22 +08:00
easterEgg: '恭喜你发现了彩蛋!',
publishPlugin: '发布插件',
publishRes: '发布资源',
closeButtonText: '关闭',
submitButtonText: '提交',
resName: '名称',
resDesc: '描述',
resAuthor: '作者',
resLink: '下载链接',
resHomepage: '主页',
resNameText: '示例:可爱风格主题',
resDescText: '示例:一个可爱风格和配色的主题',
resAuthorText: '通常为github用户名示例yanyongyu',
resLinkText: '直接下载链接通常为zip包链接',
resHomepageText: '可选可为git平台仓库名',
2024-09-01 20:39:51 +08:00
}
2024-09-01 18:25:37 +08:00
}
2024-09-01 20:39:51 +08:00
let refData = {}
function getText(lang: string, key: string): string {
lang = formatLang(lang);
2024-09-01 22:00:17 +08:00
return i18nData[lang][key];
2024-09-01 20:39:51 +08:00
}
2024-09-22 01:38:44 +08:00
export function formatLang(lang: string): string {
2024-09-01 20:39:51 +08:00
if (lang.includes('-')) {
return lang.split('-')[0];
}
return lang;
}
2024-09-01 22:00:17 +08:00
export function updateRefData() {
const lang = formatLang(useData().site.value.lang);
2024-09-01 20:39:51 +08:00
for (let key in refData) {
refData[key].value = getText(lang, key);
}
}
export function getTextRef(key: string): any {
const lang = formatLang(useData().site.value.lang);
2024-09-01 22:00:17 +08:00
refData[key] = getText(lang, key);
return refData[key] || key;
2024-09-05 11:45:12 +08:00
}