feat(i18n): 更新国际化组件,优化语言文件和结构,增强类型支持
This commit is contained in:
23
src/main.ts
23
src/main.ts
@ -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__;
|
||||
|
Reference in New Issue
Block a user