mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-12-25 22:30:19 +08:00
feat(projects): import i18n [引入i18n]
This commit is contained in:
22
src/locales/i18n.ts
Normal file
22
src/locales/i18n.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { App } from 'vue';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import messages from './lang';
|
||||
import type { LocaleKey } from './lang';
|
||||
|
||||
const i18n = createI18n({
|
||||
locale: 'zh-CN',
|
||||
fallbackLocale: 'en',
|
||||
messages
|
||||
});
|
||||
|
||||
export function setupI18n(app: App) {
|
||||
app.use(i18n);
|
||||
}
|
||||
|
||||
export function t(key: string) {
|
||||
return i18n.global.t(key);
|
||||
}
|
||||
|
||||
export function setLocale(locale: LocaleKey) {
|
||||
i18n.global.locale = locale;
|
||||
}
|
||||
Reference in New Issue
Block a user