feat(i18n): 移除国际化
All checks were successful
/ build-and-deploy-to-vercel (push) Successful in 2m8s
/ playwright (push) Successful in 2m26s
/ depcheck (push) Successful in 1m36s

This commit is contained in:
严浩
2024-11-07 10:38:42 +08:00
parent 4dd414e4bf
commit a4cc30f816
6 changed files with 16 additions and 320 deletions

View File

@ -4,23 +4,10 @@ import 'virtual:uno.css';
import { createHead } from '@unhead/vue';
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
import { createI18n } from 'vue-i18n';
import { DataLoaderPlugin } from 'unplugin-vue-router/data-loaders';
import App from './App.vue';
import { router } from './router';
// 自动导入语言文件
interface LocaleMessages {
[key: string]: string;
}
const messages = Object.fromEntries(
Object.entries(import.meta.glob<Record<string, LocaleMessages>>('./locales/*.json', { eager: true })).map(
([key, value]) => {
return [key.slice('./locales/'.length, -5), value.default];
},
),
);
async function init() {
if (import.meta.env.MODE === 'development' || 1 === 1) {
@ -42,15 +29,7 @@ async function init() {
// Register the plugin before the router
.use(DataLoaderPlugin, { router })
// adding the router will trigger the initial navigation
.use(router)
.use(
createI18n({
legacy: false, // 使用 Composition API 模式
locale: 'zh', // 默认语言
fallbackLocale: 'en', // 回退语言
messages,
}),
);
.use(router);
app.config.globalProperties.$__DEV__ = $__DEV__;
app.mount('#app');
}