Files
mobilizon-frontend/src/plugins/dateFns.ts
2025-11-29 19:10:16 +01:00

23 lines
660 B
TypeScript

import type { Locale } from "date-fns";
import { App } from "vue";
export const dateFnsPlugin = {
install(app: App, options: { locale: string }) {
function dateFnsfileForLanguage(lang: string) {
const matches: Record<string, string> = {
en: "en-US",
};
return matches[lang] ?? lang.replace("_", "-");
}
import(
`../../node_modules/date-fns/locale/${dateFnsfileForLanguage(
options.locale
)}/cdn.js`
).then((localeEntity: { default: Locale }) => {
app.provide("dateFnsLocale", localeEntity.default);
app.config.globalProperties.$dateFnsLocale = localeEntity.default;
});
},
};