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.

18 lines
505 B

4 months ago
4 months ago
  1. import { ref, computed } from 'vue'
  2. import { t, changeLanguage, availableLanguages, languagePacks } from '../lang/index'
  3. export const useLanguage = () => {
  4. const translate = computed(() => (key) => {
  5. return t.value && key in t.value ? t.value[key] : key
  6. })
  7. const currentLanguage = computed(() => t.value?.language || '简体中文')
  8. return {
  9. t,
  10. translate,
  11. changeLanguage,
  12. availableLanguages,
  13. languagePacks,
  14. currentLanguage
  15. }
  16. }