mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +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;
|
||||
}
|
1
src/locales/index.ts
Normal file
1
src/locales/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './i18n';
|
21
src/locales/lang/en.ts
Normal file
21
src/locales/lang/en.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import type { LocaleMessages } from 'vue-i18n';
|
||||
|
||||
const locale: LocaleMessages<I18nType.Schema> = {
|
||||
message: {
|
||||
system: {
|
||||
title: 'SoybeanAdmin'
|
||||
},
|
||||
routes: {
|
||||
dashboard: {
|
||||
dashboard: 'Dashboard',
|
||||
analysis: 'Analysis',
|
||||
workbench: 'Workbench'
|
||||
},
|
||||
about: {
|
||||
about: 'About'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default locale;
|
11
src/locales/lang/index.ts
Normal file
11
src/locales/lang/index.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import zhCN from './zh-cn';
|
||||
import en from './en';
|
||||
|
||||
const locales = {
|
||||
'zh-CN': zhCN,
|
||||
en
|
||||
};
|
||||
|
||||
export type LocaleKey = keyof typeof locales;
|
||||
|
||||
export default locales;
|
21
src/locales/lang/zh-cn.ts
Normal file
21
src/locales/lang/zh-cn.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import type { LocaleMessages } from 'vue-i18n';
|
||||
|
||||
const locale: LocaleMessages<I18nType.Schema> = {
|
||||
message: {
|
||||
system: {
|
||||
title: 'Soybean管理系统'
|
||||
},
|
||||
routes: {
|
||||
dashboard: {
|
||||
dashboard: '仪表盘',
|
||||
analysis: '分析页',
|
||||
workbench: '工作台'
|
||||
},
|
||||
about: {
|
||||
about: '关于'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default locale;
|
Reference in New Issue
Block a user