feat(i18n): 更新国际化组件,优化语言文件和结构,增强类型支持
All checks were successful
/ build-and-deploy-to-vercel (push) Successful in 1m16s
/ depcheck (push) Successful in 1m36s
/ playwright (push) Successful in 2m49s

This commit is contained in:
严浩
2024-11-07 15:26:33 +08:00
parent 3eed9a44df
commit 6b657f3f2b
7 changed files with 57 additions and 73 deletions

View File

@ -10,6 +10,12 @@ import App from './App.vue';
import { router } from './router';
import { createI18n } from 'vue-i18n';
/* https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n#static-bundle-importing
* All i18n resources specified in the plugin `include` option can be loaded
* at once using the import syntax
*/
import messages from '@intlify/unplugin-vue-i18n/messages';
async function init() {
if (import.meta.env.MODE === 'development' || 1 === 1) {
// TODO: https://github.com/hu3dao/vite-plugin-debug/
@ -24,6 +30,7 @@ async function init() {
});
}
console.debug(`messages :>> `, messages);
const app = createApp(App)
.use(createHead())
.use(createPinia().use(piniaPluginPersistedstate))
@ -36,21 +43,7 @@ async function init() {
createI18n({
legacy: false, // you must set `false`, to use Composition API
locale: navigator.language,
fallbackLocale: 'en',
messages: {
en: {
message: {
hello: 'hello world',
greeting: 'good morning, world!',
},
},
ja: {
message: {
hello: 'こんにちは、世界',
greeting: 'おはよう、世界!',
},
},
},
messages,
}),
);
app.config.globalProperties.$__DEV__ = $__DEV__;