diff --git a/assets/vue/composables/formatDate.js b/assets/vue/composables/formatDate.js index 55c41d74c9..de6b6ba2f1 100644 --- a/assets/vue/composables/formatDate.js +++ b/assets/vue/composables/formatDate.js @@ -1,18 +1,23 @@ -const { DateTime } = require("luxon") +import { DateTime } from "luxon" +import { useLocale } from "./locale" export function useFormatDate() { + const { appParentLocale } = useLocale() + const abbreviatedDatetime = (datetime) => { if (!datetime) { return "" } - return DateTime.fromISO(datetime).toLocaleString({ - ...DateTime.DATETIME_MED, - month: "long", - }) + return DateTime.fromISO(datetime) + .setLocale(appParentLocale.value) + .toLocaleString({ + ...DateTime.DATETIME_MED, + month: "long", + }) } - const relativeDatetime = (datetime) => DateTime.fromISO(datetime).toRelative() + const relativeDatetime = (datetime) => DateTime.fromISO(datetime).setLocale(appParentLocale.value).toRelative() return { abbreviatedDatetime, diff --git a/assets/vue/composables/locale.js b/assets/vue/composables/locale.js index 342f4fc71d..d0238b9ac4 100644 --- a/assets/vue/composables/locale.js +++ b/assets/vue/composables/locale.js @@ -84,8 +84,11 @@ export function useLocale() { window.location.href = newUrl.fullPath } + const appParentLocale = computed(() => useParentLocale(appLocale.value)) + return { appLocale, + appParentLocale, languageList, currentLanguageFromList, reloadWithLocale,