Files
vue-ts-example/src/plugins/vue-i18n/index.ts
严浩 9d421c5bfe
All checks were successful
/ playwright (push) Successful in 2m19s
/ build-and-deploy-to-vercel (push) Successful in 1m9s
/ depcheck (push) Successful in 1m5s
feat: 重构插件安装方式,统一使用 install 方法并移除不必要的 setup 函数
2024-12-24 23:13:09 +08:00

20 lines
691 B
TypeScript

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';
console.debug(`messages :>> `, messages);
export function install({ app }: { app: import('vue').App<Element> }) {
app.use(
// https://vue-i18n.intlify.dev/guide/essentials/started.html#registering-the-i18n-plugin
createI18n({
legacy: false, // you must set `false`, to use Composition API
locale: navigator.language,
messages,
}),
);
}