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.
27 lines
758 B
27 lines
758 B
import { useStore } from '@/store/root'
|
|
import type { App } from 'vue'
|
|
import { chineseLanguageLoader } from '@/i18n/util'
|
|
|
|
export const switchLanguage = {
|
|
install: (app: App<Element>) => {
|
|
const store = useStore()
|
|
|
|
app.config.globalProperties.switchLanguage = (value, key) => {
|
|
const language = store.language
|
|
let content: any
|
|
if (language === 'zh') {
|
|
content = value[key]
|
|
}
|
|
const _key = (key as string) + 'En'
|
|
if (language === 'en' && value[_key]) {
|
|
content = value[_key]
|
|
} else if (language === 'en' && !value[_key]) {
|
|
content = value[key]
|
|
}
|
|
if (language === 'tw') {
|
|
content = chineseLanguageLoader(value[key] as any)
|
|
}
|
|
return content
|
|
}
|
|
}
|
|
}
|
|
|