Appearance
国际化
框架内部集成 vue-i18n,可直接使用国际化的能力。
具体使用 参考。
配置
定义国际化文件。
src/locales/zh.ts
js
import { defineLocale } from '@gauss/prime'
export default defineLocale({
siteTitle: 'Gauss',
})import { defineLocale } from '@gauss/prime'
export default defineLocale({
siteTitle: 'Gauss',
})src/locales/en.ts
js
import { defineLocale } from '@gauss/prime'
export default defineLocale({
siteTitle: 'Gauss',
})import { defineLocale } from '@gauss/prime'
export default defineLocale({
siteTitle: 'Gauss',
})main.ts
js
import { createPrime } from '@gauss/prime'
import zh from './locales/zh'
import en from './locales/en'
const prime = createPrime({
...
i18nOptions: {
messages: {
zh,
en,
}
},
})import { createPrime } from '@gauss/prime'
import zh from './locales/zh'
import en from './locales/en'
const prime = createPrime({
...
i18nOptions: {
messages: {
zh,
en,
}
},
})使用
vue
<template>
<div>{{ $t('siteTitle') }}</div>
</template>
<script setup>
import { watch } from 'vue'
import { useI18n } from '@gauss/prime'
const { t, locale } = useI18n()
console.log(t('siteTitle'))
watch(
() => locale.value,
() => {
// TODO,国际化切换时处理
},
)
</script><template>
<div>{{ $t('siteTitle') }}</div>
</template>
<script setup>
import { watch } from 'vue'
import { useI18n } from '@gauss/prime'
const { t, locale } = useI18n()
console.log(t('siteTitle'))
watch(
() => locale.value,
() => {
// TODO,国际化切换时处理
},
)
</script>更多语言支持
系统内需支持 “繁体字段” 语言
js
import { createPrime } from '@gauss/prime'
import zh from './locales/zh'
import en from './locales/en'
import zhTW from './locales/zh-tw'
import elZhTW from 'element-plus/es/locale/lang/zh-tw'
import hamletZhTW from './locales/zh-tw/hamlet'
const prime = createPrime({
...
i18nOptions: {
codes: [{ label: '繁体中文', value: 'zh-tw' }],
messages: {
zh,
en,
'zh-tw': zhTW,
},
elementMessages: {
'zh-tw': elZhTW,
},
hamletMessages: {
'zh-tw': hamletZhTW,
},
},
})import { createPrime } from '@gauss/prime'
import zh from './locales/zh'
import en from './locales/en'
import zhTW from './locales/zh-tw'
import elZhTW from 'element-plus/es/locale/lang/zh-tw'
import hamletZhTW from './locales/zh-tw/hamlet'
const prime = createPrime({
...
i18nOptions: {
codes: [{ label: '繁体中文', value: 'zh-tw' }],
messages: {
zh,
en,
'zh-tw': zhTW,
},
elementMessages: {
'zh-tw': elZhTW,
},
hamletMessages: {
'zh-tw': hamletZhTW,
},
},
})框架国际化字段
您可以修改定义文件来覆盖框架本身的国际化字段。
zh
ts
export default {
siteTitle: 'Gauss',
message: {
tip: '提示',
},
watermark: {
development: '测试环境',
product: '正式环境',
},
login: {
hello: {
morning: '上午好',
afternoon: '下午好',
evening: '晚上好',
},
tip: '登录到您的账户',
submitTxt: '登录',
userName: '账户',
password: '密码',
rules: {
userName: '请输入账户',
password: '请输入密码',
},
welcomeTo: '欢迎来到',
},
role: {
default: '默认',
repeat: '当前角色已登录!',
switchSuccess: '角色切换成功!',
switchFail: '角色切换失败!',
},
logout: {
menu: '退出登录',
messageBox: {
tip: '温馨提示',
cancelTxt: '取消',
confirmTxt: '确认',
message: '您是否确认退出登录?',
},
success: '退出登录成功!',
},
theme: {
title: '布局设置',
switchLayout: '导航模式',
globalTheme: '全局主题',
primaryColor: '主题颜色',
grey: '灰色模式',
ui: '界面设置',
tabs: '标签栏',
tabsIcon: '标签栏图标',
asideInverted: '侧边栏反转',
log: '日志采集',
menuInverted: '一级菜单与子级菜单位置反转',
navigationBarColor: '导航栏颜色',
},
404: {
oops: 'OOPS!',
info: '抱歉,你访问的页面不存在,请检查地址是否正确或点击返回首页。',
home: '返回首页',
},
403: {
oops: 'OOPS!',
info: '禁止访问,总有些门是对你关闭的。',
login: '返回登录页',
},
auth: {
title: '提示',
message: '您暂无权限访问,请重新登录',
},
autoLoginFailed: {
title: '提示',
message: '授权登录编码失败,请重试!',
confirmButtonText: '跳转登录页',
cancelButtonText: '返回',
},
search: {
placeholder: '搜索...',
autocompletePlaceholder: '菜单搜索 :支持菜单名称、路径',
},
messages: {
tip: '通知',
more: '查看更多',
title: '站内信',
buttons: {
read: '标记已读',
delete: '删除',
},
checkboxLabel: '全选',
readStatus: {
all: '全部',
read: '已读',
unread: '未读',
},
deleteDialog: {
title: '删除',
content: '是否确认删除选择的信件?',
cancelText: '取消',
okText: '确认',
},
empty: '暂无通知',
},
tabs: {
refresh: '刷新',
maximize: '最大化',
close: {
other: '关闭其它',
all: '关闭所有',
},
favorite: {
title: '我的收藏',
empty: '收藏夹是空的',
tip: {
prefix: '点击右上角',
suffix: '将当前页面添加到收藏夹',
},
},
},
routeMetaTitle: {
system: {
user: '用户管理',
menus: '菜单管理',
role: '角色管理',
myDepartment: '我的部门',
dict: '字典管理',
file: '文件管理',
fileStorage: '文件仓管理',
systemSetting: '系统设置',
},
},
construction: '系统建设中,敬请期待…',
language: {
international: '国际化',
},
}export default {
siteTitle: 'Gauss',
message: {
tip: '提示',
},
watermark: {
development: '测试环境',
product: '正式环境',
},
login: {
hello: {
morning: '上午好',
afternoon: '下午好',
evening: '晚上好',
},
tip: '登录到您的账户',
submitTxt: '登录',
userName: '账户',
password: '密码',
rules: {
userName: '请输入账户',
password: '请输入密码',
},
welcomeTo: '欢迎来到',
},
role: {
default: '默认',
repeat: '当前角色已登录!',
switchSuccess: '角色切换成功!',
switchFail: '角色切换失败!',
},
logout: {
menu: '退出登录',
messageBox: {
tip: '温馨提示',
cancelTxt: '取消',
confirmTxt: '确认',
message: '您是否确认退出登录?',
},
success: '退出登录成功!',
},
theme: {
title: '布局设置',
switchLayout: '导航模式',
globalTheme: '全局主题',
primaryColor: '主题颜色',
grey: '灰色模式',
ui: '界面设置',
tabs: '标签栏',
tabsIcon: '标签栏图标',
asideInverted: '侧边栏反转',
log: '日志采集',
menuInverted: '一级菜单与子级菜单位置反转',
navigationBarColor: '导航栏颜色',
},
404: {
oops: 'OOPS!',
info: '抱歉,你访问的页面不存在,请检查地址是否正确或点击返回首页。',
home: '返回首页',
},
403: {
oops: 'OOPS!',
info: '禁止访问,总有些门是对你关闭的。',
login: '返回登录页',
},
auth: {
title: '提示',
message: '您暂无权限访问,请重新登录',
},
autoLoginFailed: {
title: '提示',
message: '授权登录编码失败,请重试!',
confirmButtonText: '跳转登录页',
cancelButtonText: '返回',
},
search: {
placeholder: '搜索...',
autocompletePlaceholder: '菜单搜索 :支持菜单名称、路径',
},
messages: {
tip: '通知',
more: '查看更多',
title: '站内信',
buttons: {
read: '标记已读',
delete: '删除',
},
checkboxLabel: '全选',
readStatus: {
all: '全部',
read: '已读',
unread: '未读',
},
deleteDialog: {
title: '删除',
content: '是否确认删除选择的信件?',
cancelText: '取消',
okText: '确认',
},
empty: '暂无通知',
},
tabs: {
refresh: '刷新',
maximize: '最大化',
close: {
other: '关闭其它',
all: '关闭所有',
},
favorite: {
title: '我的收藏',
empty: '收藏夹是空的',
tip: {
prefix: '点击右上角',
suffix: '将当前页面添加到收藏夹',
},
},
},
routeMetaTitle: {
system: {
user: '用户管理',
menus: '菜单管理',
role: '角色管理',
myDepartment: '我的部门',
dict: '字典管理',
file: '文件管理',
fileStorage: '文件仓管理',
systemSetting: '系统设置',
},
},
construction: '系统建设中,敬请期待…',
language: {
international: '国际化',
},
}en
ts
export default {
siteTitle: 'Gauss',
message: {
tip: 'Tips',
},
watermark: {
development: 'Testing Environment',
product: 'Production Environment',
},
login: {
hello: {
morning: 'Good Morning',
afternoon: 'Good Afternoon',
evening: 'Good Evening',
},
tip: 'Log in to your account',
submitTxt: 'Log in',
userName: 'Username',
password: 'Password',
rules: {
userName: 'Please enter your username',
password: 'Please enter your password',
},
welcomeTo: 'Welcome to',
},
logout: {
menu: 'Log out',
messageBox: {
tip: 'Tips',
cancelTxt: 'Cancel',
confirmTxt: 'OK',
message: 'Are you sure to log out?',
},
success: 'Log out successfully!',
},
role: {
default: 'Default',
repeat: 'The current role has logged in!',
switchSuccess: 'Switch role successfully!',
switchFail: 'Switch role failed!',
},
theme: {
title: 'Layout Setting',
switchLayout: 'Navigation Mode',
globalTheme: 'Global Theme',
primaryColor: 'Theme Color',
grey: 'Grey Mode',
ui: 'Layout Setting',
tabs: 'Tabs',
tabsIcon: 'Tab Icon',
asideInverted: 'Sidebar Inversion',
log: 'Error Log',
menuInverted: 'First-level menu and sub-level menu position inversion',
navigationBarColor: 'Navigation Bar Color',
},
404: {
oops: 'OOPS!',
info: 'Sorry, the page you visit is not exist, Please check the URL you entered is correct. And click the button below to return the homepage',
home: 'Back to homepage',
},
403: {
oops: 'OOPS!',
info: 'You don’t have permission to access this page.',
login: 'Back to login',
},
auth: {
title: 'Tips',
message: 'You have no permission to access',
},
autoLoginFailed: {
title: 'Tips',
message: 'Authorization login code failed. Please try again!',
confirmButtonText: 'Jump to Login',
cancelButtonText: 'Back',
},
search: {
placeholder: 'search...',
autocompletePlaceholder: 'Menu search: Supports menu names and paths',
},
messages: {
tip: 'Notification',
more: 'More',
title: 'Messages',
buttons: {
read: 'Mark Read',
delete: 'Delete',
},
checkboxLabel: 'All',
readStatus: {
all: 'All',
read: 'Read',
unread: 'Unread',
},
deleteDialog: {
title: 'Delete',
content: 'Do you want to delete the selected messages?',
cancelText: 'Cancel',
okText: 'OK',
},
empty: 'No Messages',
},
tabs: {
refresh: 'Refresh',
maximize: 'Maximize',
close: {
other: 'Close Other',
all: 'Close All',
},
favorite: {
title: 'Favorites',
empty: 'Favorites are empty',
tip: {
prefix: 'Click on top right corner',
suffix: 'adds the page to your favorites',
},
},
},
systemMenu: {
system: 'System',
userManagement: 'User',
useMenu: 'Menus',
useRole: 'Roles',
myDepartment: 'My Department',
dictManagement: 'Dicts',
fileManagement: 'File',
storageRepoManagement: 'File Storage',
systemSettings: 'System Setting',
},
routeMetaTitle: {
system: {
user: 'User',
menus: 'Menus',
role: 'Roles',
myDepartment: 'My Department',
dict: 'Dicts',
file: 'File',
fileStorage: 'File Storage',
systemSetting: 'System Setting',
},
},
construction: 'System construction, please look forward to...',
language: {
international: 'International',
},
}export default {
siteTitle: 'Gauss',
message: {
tip: 'Tips',
},
watermark: {
development: 'Testing Environment',
product: 'Production Environment',
},
login: {
hello: {
morning: 'Good Morning',
afternoon: 'Good Afternoon',
evening: 'Good Evening',
},
tip: 'Log in to your account',
submitTxt: 'Log in',
userName: 'Username',
password: 'Password',
rules: {
userName: 'Please enter your username',
password: 'Please enter your password',
},
welcomeTo: 'Welcome to',
},
logout: {
menu: 'Log out',
messageBox: {
tip: 'Tips',
cancelTxt: 'Cancel',
confirmTxt: 'OK',
message: 'Are you sure to log out?',
},
success: 'Log out successfully!',
},
role: {
default: 'Default',
repeat: 'The current role has logged in!',
switchSuccess: 'Switch role successfully!',
switchFail: 'Switch role failed!',
},
theme: {
title: 'Layout Setting',
switchLayout: 'Navigation Mode',
globalTheme: 'Global Theme',
primaryColor: 'Theme Color',
grey: 'Grey Mode',
ui: 'Layout Setting',
tabs: 'Tabs',
tabsIcon: 'Tab Icon',
asideInverted: 'Sidebar Inversion',
log: 'Error Log',
menuInverted: 'First-level menu and sub-level menu position inversion',
navigationBarColor: 'Navigation Bar Color',
},
404: {
oops: 'OOPS!',
info: 'Sorry, the page you visit is not exist, Please check the URL you entered is correct. And click the button below to return the homepage',
home: 'Back to homepage',
},
403: {
oops: 'OOPS!',
info: 'You don’t have permission to access this page.',
login: 'Back to login',
},
auth: {
title: 'Tips',
message: 'You have no permission to access',
},
autoLoginFailed: {
title: 'Tips',
message: 'Authorization login code failed. Please try again!',
confirmButtonText: 'Jump to Login',
cancelButtonText: 'Back',
},
search: {
placeholder: 'search...',
autocompletePlaceholder: 'Menu search: Supports menu names and paths',
},
messages: {
tip: 'Notification',
more: 'More',
title: 'Messages',
buttons: {
read: 'Mark Read',
delete: 'Delete',
},
checkboxLabel: 'All',
readStatus: {
all: 'All',
read: 'Read',
unread: 'Unread',
},
deleteDialog: {
title: 'Delete',
content: 'Do you want to delete the selected messages?',
cancelText: 'Cancel',
okText: 'OK',
},
empty: 'No Messages',
},
tabs: {
refresh: 'Refresh',
maximize: 'Maximize',
close: {
other: 'Close Other',
all: 'Close All',
},
favorite: {
title: 'Favorites',
empty: 'Favorites are empty',
tip: {
prefix: 'Click on top right corner',
suffix: 'adds the page to your favorites',
},
},
},
systemMenu: {
system: 'System',
userManagement: 'User',
useMenu: 'Menus',
useRole: 'Roles',
myDepartment: 'My Department',
dictManagement: 'Dicts',
fileManagement: 'File',
storageRepoManagement: 'File Storage',
systemSettings: 'System Setting',
},
routeMetaTitle: {
system: {
user: 'User',
menus: 'Menus',
role: 'Roles',
myDepartment: 'My Department',
dict: 'Dicts',
file: 'File',
fileStorage: 'File Storage',
systemSetting: 'System Setting',
},
},
construction: 'System construction, please look forward to...',
language: {
international: 'International',
},
}
Gauss