You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
547 B
22 lines
547 B
import i18n, { language } from './i18n'
|
|
import useAppStore from '@/stores/modules/app'
|
|
|
|
const t = (message: string) => {
|
|
const route = useAppStore().route
|
|
const path = route.meta.view || route.path
|
|
const file =
|
|
path == '/'
|
|
? 'index'
|
|
: path.replace(/^(\/admin\/|\/site\/|\/)/, '').replaceAll('/', '.')
|
|
const key = `${file}.${message}`
|
|
return i18n.global.t(key) != key ? i18n.global.t(key) : i18n.global.t(message)
|
|
}
|
|
|
|
export { language, t }
|
|
|
|
export default {
|
|
install(app: any) {
|
|
//注册i18n
|
|
app.use(i18n)
|
|
},
|
|
}
|
|
|