feat(i18n): 添加国际化支持,更新语言切换功能
This commit is contained in:
21
src/main.ts
21
src/main.ts
@ -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');
|
||||
}
|
||||
|
Reference in New Issue
Block a user