嘉兴绿城濮院
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.
 
 
 
 

26 lines
843 B

import { useStore } from '@/store'
import type { App } from 'vue'
import { chineseLanguageLoader } from '@/i18n/util'
export const switchLanguage = {
install: (app: App<Element>) => {
const store = useStore()
app.config.globalProperties.switchLanguage = <V extends object, K extends keyof V>(value: V, key: K): V[K] => {
const language = store.language
let content: any
if (language === 'zh') {
content = value[key]
}
if (language === 'en' && value[(key + 'En') as keyof typeof value]) {
content = value[(key + 'En') as keyof typeof value]
} else if (language === 'en' && !value[(key + 'En') as keyof typeof value]) {
content = value[key]
}
if (language === 'tw') {
content = chineseLanguageLoader(value[key])
}
return content
}
}
}