You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			28 lines
		
	
	
		
			586 B
		
	
	
	
		
			TypeScript
		
	
			
		
		
	
	
			28 lines
		
	
	
		
			586 B
		
	
	
	
		
			TypeScript
		
	
| import { computed } from 'vue'
 | |
| import { enUS, zhCN, zhTW } from 'naive-ui'
 | |
| import { useAppStore } from '@/store'
 | |
| import { setLocale } from '@/locales'
 | |
| 
 | |
| export function useLanguage() {
 | |
|   const appStore = useAppStore()
 | |
| 
 | |
|   const language = computed(() => {
 | |
|     switch (appStore.language) {
 | |
|       case 'en-US':
 | |
|         setLocale('en-US')
 | |
|         return enUS
 | |
|       case 'zh-CN':
 | |
|         setLocale('zh-CN')
 | |
|         return zhCN
 | |
|       case 'zh-TW':
 | |
|         setLocale('zh-TW')
 | |
|         return zhTW
 | |
|       default:
 | |
|         setLocale('zh-CN')
 | |
|         return zhCN
 | |
|     }
 | |
|   })
 | |
| 
 | |
|   return { language }
 | |
| }
 |