fix: disable dayjsLanguageSync function
This commit is contained in:
parent
b8e7b87f96
commit
e1f49f2ff1
@ -1,4 +1,3 @@
|
|||||||
import {computed, ref, watch} from 'vue'
|
|
||||||
import {createI18n} from 'vue-i18n'
|
import {createI18n} from 'vue-i18n'
|
||||||
import langEN from './lang/en.json'
|
import langEN from './lang/en.json'
|
||||||
|
|
||||||
@ -89,35 +88,33 @@ export function setLanguage() {
|
|||||||
return loadLanguageAsync(getCurrentLanguage())
|
return loadLanguageAsync(getCurrentLanguage())
|
||||||
}
|
}
|
||||||
|
|
||||||
import type dayjs from 'dayjs'
|
|
||||||
|
|
||||||
// FIXME: This function is not used at the moment because it does not seem to work.
|
// FIXME: This function is not used at the moment because it does not seem to work.
|
||||||
// It should be reworked and cleaned up. An even better way would be to get rid of
|
// It should be reworked and cleaned up. An even better way would be to get rid of
|
||||||
// this completely by using date-fns for everything.
|
// this completely by using date-fns for everything.
|
||||||
export function useDayjsLanguageSync(dayjsGlobal: typeof dayjs) {
|
// export function useDayjsLanguageSync(dayjsGlobal: typeof dayjs) {
|
||||||
const dayjsLanguageLoaded = ref(false)
|
// const dayjsLanguageLoaded = ref(false)
|
||||||
watch(
|
// watch(
|
||||||
() => i18n.global.locale,
|
// () => i18n.global.locale,
|
||||||
async (currentLanguage: string) => {
|
// async (currentLanguage: string) => {
|
||||||
if (!dayjsGlobal) {
|
// if (!dayjsGlobal) {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
const dayjsLanguageCode = DAYJS_LOCALE_MAPPING[currentLanguage.toLowerCase()] || currentLanguage.toLowerCase()
|
// const dayjsLanguageCode = DAYJS_LOCALE_MAPPING[currentLanguage.toLowerCase()] || currentLanguage.toLowerCase()
|
||||||
dayjsLanguageLoaded.value = dayjsGlobal.locale() === dayjsLanguageCode
|
// dayjsLanguageLoaded.value = dayjsGlobal.locale() === dayjsLanguageCode
|
||||||
if (dayjsLanguageLoaded.value) {
|
// if (dayjsLanguageLoaded.value) {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
console.log('foo')
|
// console.log('foo')
|
||||||
await import(`../../node_modules/dayjs/locale/${dayjsLanguageCode}.js`)
|
// await import(`../../node_modules/dayjs/locale/${dayjsLanguageCode}.js`)
|
||||||
console.log('bar')
|
// console.log('bar')
|
||||||
dayjsGlobal.locale(dayjsLanguageCode)
|
// dayjsGlobal.locale(dayjsLanguageCode)
|
||||||
dayjsLanguageLoaded.value = true
|
// dayjsLanguageLoaded.value = true
|
||||||
},
|
// },
|
||||||
{immediate: true},
|
// {immediate: true},
|
||||||
)
|
// )
|
||||||
|
//
|
||||||
// we export the loading state since that's easier to work with
|
// // we export the loading state since that's easier to work with
|
||||||
const isLoading = computed(() => !dayjsLanguageLoaded.value)
|
// const isLoading = computed(() => !dayjsLanguageLoaded.value)
|
||||||
|
//
|
||||||
return isLoading
|
// return isLoading
|
||||||
}
|
// }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user