feat(i18n): 添加国际化支持,更新语言切换功能
All checks were successful
/ build-and-deploy-to-vercel (push) Successful in 2m20s
/ depcheck (push) Successful in 2m27s
/ playwright (push) Successful in 2m1s

This commit is contained in:
严浩
2024-11-06 17:44:32 +08:00
parent e2f60c32a3
commit 40752e555f
6 changed files with 94 additions and 17 deletions

View File

@ -4,6 +4,7 @@ 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';
@ -29,7 +30,25 @@ async function init() {
// Register the plugin before the router
.use(DataLoaderPlugin, { router })
// adding the router will trigger the initial navigation
.use(router);
.use(router)
.use(
createI18n({
locale: 'zh_CN', // 默认显示语言
fallbackLocale: 'zh_CN',
messages: {
en_US: {
message: {
hello: 'hello',
},
},
zh_CN: {
message: {
hello: '你好',
},
},
},
}),
);
app.config.globalProperties.$__DEV__ = $__DEV__;
app.mount('#app');
}